未验证 提交 51b8463e 编写于 作者: D dotnet-automerge-bot 提交者: GitHub

Merge pull request #33777 from dotnet/merges/master-to-features/readonly-members

Merge master to features/readonly-members
...@@ -63,6 +63,17 @@ dotnet_naming_symbols.non_private_static_fields.required_modifiers = static ...@@ -63,6 +63,17 @@ dotnet_naming_symbols.non_private_static_fields.required_modifiers = static
dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case
# Non-private readonly fields are PascalCase
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_readonly_field_style
dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field
dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, protected, internal, protected internal, private protected
dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly
dotnet_naming_style.non_private_readonly_field_style.capitalization = pascal_case
# Constants are PascalCase # Constants are PascalCase
dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants
......
...@@ -280,6 +280,7 @@ EndProject ...@@ -280,6 +280,7 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.IntegrationTest.Setup", "src\VisualStudio\IntegrationTest\TestSetup\Microsoft.VisualStudio.IntegrationTest.Setup.csproj", "{A88AB44F-7F9D-43F6-A127-83BB65E5A7E2}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.IntegrationTest.Setup", "src\VisualStudio\IntegrationTest\TestSetup\Microsoft.VisualStudio.IntegrationTest.Setup.csproj", "{A88AB44F-7F9D-43F6-A127-83BB65E5A7E2}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{600AF682-E097-407B-AD85-EE3CED37E680} = {600AF682-E097-407B-AD85-EE3CED37E680} {600AF682-E097-407B-AD85-EE3CED37E680} = {600AF682-E097-407B-AD85-EE3CED37E680}
{A486D7DE-F614-409D-BB41-0FFDF582E35C} = {A486D7DE-F614-409D-BB41-0FFDF582E35C}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.IntegrationTests", "src\VisualStudio\IntegrationTest\IntegrationTests\Microsoft.VisualStudio.LanguageServices.IntegrationTests.csproj", "{E5A55C16-A5B9-4874-9043-A5266DC02F58}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.IntegrationTests", "src\VisualStudio\IntegrationTest\IntegrationTests\Microsoft.VisualStudio.LanguageServices.IntegrationTests.csproj", "{E5A55C16-A5B9-4874-9043-A5266DC02F58}"
......
...@@ -11,24 +11,19 @@ Using the command line Roslyn can be developed using the following pattern: ...@@ -11,24 +11,19 @@ Using the command line Roslyn can be developed using the following pattern:
## Recommended version of .NET Framework ## Recommended version of .NET Framework
The minimal required version of .NET Framework is 4.6, however 4.7.2 is recommended for best developer experience. The minimal required version of .NET Framework is 4.7.2.
The projects in this repository are configured to build with Portable PDBs, which are supported in stack traces starting with .NET Framework 4.7.2. ## Developing with Visual Studio 2019
If a stack trace is displayed on .NET Framework older than 4.7.2 (e.g. by xUnit when a test fails) it won't contain source and line information.
.NET Framework 4.7.2 is included in [Windows 10 April 2018 Update](https://blogs.windows.com/windowsexperience/2018/04/30/how-to-get-the-windows-10-april-2018-update/). It can also be installed from the [Microsoft Download Center](https://www.microsoft.com/net/download/dotnet-framework-runtime). 1. [Visual Studio 2019 Preview 4](https://www.visualstudio.com/vs/preview/)
## Developing with Visual Studio 2017
1. [Visual Studio 2017 Version 15.7](https://www.visualstudio.com/vs/preview/)
- Ensure C#, VB, MSBuild, .NET Core and Visual Studio Extensibility are included in the selected work loads - Ensure C#, VB, MSBuild, .NET Core and Visual Studio Extensibility are included in the selected work loads
- Ensure Visual Studio is on Version "15.7" or greater - Ensure Visual Studio is on Version "Preview 4" or greater
1. [.NET Core SDK 2.1.401](https://www.microsoft.com/net/download/core) (the installers are: [Windows x64 installer](https://dotnetcli.blob.core.windows.net/dotnet/Sdk/2.1.401/dotnet-sdk-2.1.401-win-x64.exe), [Windows x86 installer](https://dotnetcli.blob.core.windows.net/dotnet/Sdk/2.1.401/dotnet-sdk-2.1.401-win-x86.exe)) 1. [.NET Core SDK 2.1.401](https://www.microsoft.com/net/download/core) (the installers are: [Windows x64 installer](https://dotnetcli.blob.core.windows.net/dotnet/Sdk/2.1.401/dotnet-sdk-2.1.401-win-x64.exe), [Windows x86 installer](https://dotnetcli.blob.core.windows.net/dotnet/Sdk/2.1.401/dotnet-sdk-2.1.401-win-x86.exe))
1. [PowerShell 3.0 or newer](https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell). If you are on Windows 10, you are fine; you'll only need to upgrade if you're on Windows 7. The download link is under the "upgrading existing Windows PowerShell" heading. 1. [PowerShell 3.0 or newer](https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell). If you are on Windows 10, you are fine; you'll only need to upgrade if you're on Windows 7. The download link is under the "upgrading existing Windows PowerShell" heading.
1. Run Restore.cmd 1. Run Restore.cmd
1. Open Roslyn.sln 1. Open Roslyn.sln
If you already installed Visual Studio and need to add the necessary work loads or move to version 15.7: If you already installed Visual Studio and need to add the necessary work loads or move to Preview 4:
do the following: do the following:
- Run the Visual Studio Installer from your start menu. You can just search for "Visual Studio Installer". If you can't find it, it's typically located at "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" - Run the Visual Studio Installer from your start menu. You can just search for "Visual Studio Installer". If you can't find it, it's typically located at "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe"
...@@ -44,7 +39,7 @@ There are a number of options for running the core Roslyn unit tests: ...@@ -44,7 +39,7 @@ There are a number of options for running the core Roslyn unit tests:
The Test.cmd script will run our unit test on already built binaries. It can be passed the -build arguments to force a new build before running tests. The Test.cmd script will run our unit test on already built binaries. It can be passed the -build arguments to force a new build before running tests.
1. Run the "Developer Command Prompt for VS2017" from your start menu. 1. Run the "Developer Command Prompt for VS2019" from your start menu.
2. Navigate to the directory of your Git clone. 2. Navigate to the directory of your Git clone.
3. Run `msbuild /v:m /m /nodereuse:false BuildAndTest.proj` in the command prompt. 3. Run `msbuild /v:m /m /nodereuse:false BuildAndTest.proj` in the command prompt.
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
<Dependencies> <Dependencies>
<ProductDependencies></ProductDependencies> <ProductDependencies></ProductDependencies>
<ToolsetDependencies> <ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="1.0.0-beta.19126.6"> <Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="1.0.0-beta.19127.8">
<Uri>https://github.com/dotnet/arcade</Uri> <Uri>https://github.com/dotnet/arcade</Uri>
<Sha>3f38c38af31863b35c9334320b95cca56e29c942</Sha> <Sha>f393a6b6b2df0854e051f314977137d31855b6c8</Sha>
</Dependency> </Dependency>
</ToolsetDependencies> </ToolsetDependencies>
</Dependencies> </Dependencies>
...@@ -68,10 +68,9 @@ ...@@ -68,10 +68,9 @@
<MicrosoftMetadataVisualizerVersion>1.0.0-beta1-63011-01</MicrosoftMetadataVisualizerVersion> <MicrosoftMetadataVisualizerVersion>1.0.0-beta1-63011-01</MicrosoftMetadataVisualizerVersion>
<MicrosoftMSXMLVersion>8.0.0.0-alpha</MicrosoftMSXMLVersion> <MicrosoftMSXMLVersion>8.0.0.0-alpha</MicrosoftMSXMLVersion>
<MicrosoftNetFrameworkReferenceAssembliesVersion>1.0.0-alpha-004</MicrosoftNetFrameworkReferenceAssembliesVersion> <MicrosoftNetFrameworkReferenceAssembliesVersion>1.0.0-alpha-004</MicrosoftNetFrameworkReferenceAssembliesVersion>
<MicrosoftNetCompilersVersion>3.0.0-beta2-19068-12</MicrosoftNetCompilersVersion> <MicrosoftNetCompilersToolsetVersion>3.1.0-beta1-19127-06</MicrosoftNetCompilersToolsetVersion>
<MicrosoftNetCoreAnalyzersVersion>$(RoslynDiagnosticsNugetPackageVersion)</MicrosoftNetCoreAnalyzersVersion> <MicrosoftNetCoreAnalyzersVersion>$(RoslynDiagnosticsNugetPackageVersion)</MicrosoftNetCoreAnalyzersVersion>
<MicrosoftNetCoreILAsmVersion>2.0.0</MicrosoftNetCoreILAsmVersion> <MicrosoftNetCoreILAsmVersion>2.0.0</MicrosoftNetCoreILAsmVersion>
<MicrosoftNETCoreCompilersVersion>3.0.0-beta2-19068-12</MicrosoftNETCoreCompilersVersion>
<MicrosoftNETCorePlatformsVersion>2.1.0</MicrosoftNETCorePlatformsVersion> <MicrosoftNETCorePlatformsVersion>2.1.0</MicrosoftNETCorePlatformsVersion>
<MicrosoftNETCoreRuntimeCoreCLRVersion>2.0.0</MicrosoftNETCoreRuntimeCoreCLRVersion> <MicrosoftNETCoreRuntimeCoreCLRVersion>2.0.0</MicrosoftNETCoreRuntimeCoreCLRVersion>
<!-- Using a private build of Microsoft.Net.Test.SDK to work around issue https://github.com/Microsoft/vstest/issues/1764 --> <!-- Using a private build of Microsoft.Net.Test.SDK to work around issue https://github.com/Microsoft/vstest/issues/1764 -->
...@@ -279,8 +278,8 @@ ...@@ -279,8 +278,8 @@
<UsingToolXliff>true</UsingToolXliff> <UsingToolXliff>true</UsingToolXliff>
<UsingToolXUnit>true</UsingToolXUnit> <UsingToolXUnit>true</UsingToolXUnit>
<!-- <!--
Use compilers in Microsoft.NET.Compilers package unless we are building with bootstrapped compilers. When using a bootstrap builder we don't want to use the Microsoft.Net.Compilers.Toolset package but
Allows to dogfood the latest compiler features. rather explicitly override it.
--> -->
<UsingToolMicrosoftNetCompilers Condition="'$(BootstrapBuildPath)' == ''">true</UsingToolMicrosoftNetCompilers> <UsingToolMicrosoftNetCompilers Condition="'$(BootstrapBuildPath)' == ''">true</UsingToolMicrosoftNetCompilers>
</PropertyGroup> </PropertyGroup>
......
...@@ -188,7 +188,7 @@ ...@@ -188,7 +188,7 @@
<!-- C# specific settings --> <!-- C# specific settings -->
<When Condition="'$(Language)' == 'C#'"> <When Condition="'$(Language)' == 'C#'">
<PropertyGroup> <PropertyGroup>
<LangVersion>7.3</LangVersion> <LangVersion>8.0</LangVersion>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
......
...@@ -7,6 +7,6 @@ ...@@ -7,6 +7,6 @@
"xcopy-msbuild": "15.9.0-alpha" "xcopy-msbuild": "15.9.0-alpha"
}, },
"msbuild-sdks": { "msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19126.6" "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19127.8"
} }
} }
...@@ -994,7 +994,7 @@ ...@@ -994,7 +994,7 @@
<value>A params parameter must be the last parameter in a formal parameter list</value> <value>A params parameter must be the last parameter in a formal parameter list</value>
</data> </data>
<data name="ERR_SizeofUnsafe" xml:space="preserve"> <data name="ERR_SizeofUnsafe" xml:space="preserve">
<value>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)</value> <value>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context</value>
</data> </data>
<data name="ERR_DottedTypeNameNotFoundInNS" xml:space="preserve"> <data name="ERR_DottedTypeNameNotFoundInNS" xml:space="preserve">
<value>The type or namespace name '{0}' does not exist in the namespace '{1}' (are you missing an assembly reference?)</value> <value>The type or namespace name '{0}' does not exist in the namespace '{1}' (are you missing an assembly reference?)</value>
......
...@@ -1296,17 +1296,19 @@ public override BoundNode VisitObjectCreationExpression(BoundObjectCreationExpre ...@@ -1296,17 +1296,19 @@ public override BoundNode VisitObjectCreationExpression(BoundObjectCreationExpre
int slot = -1; int slot = -1;
TypeSymbol type = node.Type; TypeSymbol type = node.Type;
NullableAnnotation resultAnnotation = NullableAnnotation.NotNullable;
if ((object)type != null) if ((object)type != null)
{ {
bool isTrackableStructType = EmptyStructTypeCache.IsTrackableStructType(type); bool isTrackableStructType = EmptyStructTypeCache.IsTrackableStructType(type);
var constructor = (node as BoundObjectCreationExpression)?.Constructor;
bool isDefaultValueTypeConstructor = constructor?.IsDefaultValueTypeConstructor() == true;
if (!type.IsValueType || isTrackableStructType) if (!type.IsValueType || isTrackableStructType)
{ {
slot = GetOrCreateObjectCreationPlaceholderSlot(node); slot = GetOrCreateObjectCreationPlaceholderSlot(node);
if (slot > 0 && isTrackableStructType) if (slot > 0 && isTrackableStructType)
{ {
this.State[slot] = NullableAnnotation.NotNullable; this.State[slot] = NullableAnnotation.NotNullable;
var constructor = (node as BoundObjectCreationExpression)?.Constructor;
bool isDefaultValueTypeConstructor = constructor?.IsDefaultValueTypeConstructor() == true;
var tupleType = constructor?.ContainingType as TupleTypeSymbol; var tupleType = constructor?.ContainingType as TupleTypeSymbol;
if ((object)tupleType != null && !isDefaultValueTypeConstructor) if ((object)tupleType != null && !isDefaultValueTypeConstructor)
{ {
...@@ -1323,6 +1325,11 @@ public override BoundNode VisitObjectCreationExpression(BoundObjectCreationExpre ...@@ -1323,6 +1325,11 @@ public override BoundNode VisitObjectCreationExpression(BoundObjectCreationExpre
} }
} }
} }
else if (type.IsNullableType() && isDefaultValueTypeConstructor)
{
// a nullable value type created with its default constructor is by definition null
resultAnnotation = NullableAnnotation.Nullable;
}
} }
if (initializerOpt != null) if (initializerOpt != null)
...@@ -1330,7 +1337,7 @@ public override BoundNode VisitObjectCreationExpression(BoundObjectCreationExpre ...@@ -1330,7 +1337,7 @@ public override BoundNode VisitObjectCreationExpression(BoundObjectCreationExpre
VisitObjectCreationInitializer(null, slot, initializerOpt); VisitObjectCreationInitializer(null, slot, initializerOpt);
} }
ResultType = TypeSymbolWithAnnotations.Create(type, NullableAnnotation.NotNullable); ResultType = TypeSymbolWithAnnotations.Create(type, resultAnnotation);
} }
private void VisitObjectCreationInitializer(Symbol containingSymbol, int containingSlot, BoundExpression node) private void VisitObjectCreationInitializer(Symbol containingSymbol, int containingSlot, BoundExpression node)
......
...@@ -2653,8 +2653,8 @@ ...@@ -2653,8 +2653,8 @@
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_SizeofUnsafe"> <trans-unit id="ERR_SizeofUnsafe">
<source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)</source> <source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context</source>
<target state="translated">'{0} nemá předdefinovanou velikost. Operátor sizeof jde proto použít jenom v kontextu unsafe (zvažte možnost použití operátoru System.Runtime.InteropServices.Marshal.SizeOf).</target> <target state="needs-review-translation">'{0} nemá předdefinovanou velikost. Operátor sizeof jde proto použít jenom v kontextu unsafe (zvažte možnost použití operátoru System.Runtime.InteropServices.Marshal.SizeOf).</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_DottedTypeNameNotFoundInNS"> <trans-unit id="ERR_DottedTypeNameNotFoundInNS">
......
...@@ -2653,8 +2653,8 @@ ...@@ -2653,8 +2653,8 @@
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_SizeofUnsafe"> <trans-unit id="ERR_SizeofUnsafe">
<source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)</source> <source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context</source>
<target state="translated">'"{0}" enthält keine vordefinierte Größe, sizeof kann daher nur in einem ungeschützten Kontext verwendet werden (verwenden Sie ggf. System.Runtime.InteropServices.Marshal.SizeOf).</target> <target state="needs-review-translation">'"{0}" enthält keine vordefinierte Größe, sizeof kann daher nur in einem ungeschützten Kontext verwendet werden (verwenden Sie ggf. System.Runtime.InteropServices.Marshal.SizeOf).</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_DottedTypeNameNotFoundInNS"> <trans-unit id="ERR_DottedTypeNameNotFoundInNS">
......
...@@ -2653,8 +2653,8 @@ ...@@ -2653,8 +2653,8 @@
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_SizeofUnsafe"> <trans-unit id="ERR_SizeofUnsafe">
<source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)</source> <source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context</source>
<target state="translated">'{0}' no tiene un tamaño predefinido; por tanto, sizeof solo se puede usar en un contexto no seguro (use System.Runtime.InteropServices.Marshal.SizeOf).</target> <target state="needs-review-translation">'{0}' no tiene un tamaño predefinido; por tanto, sizeof solo se puede usar en un contexto no seguro (use System.Runtime.InteropServices.Marshal.SizeOf).</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_DottedTypeNameNotFoundInNS"> <trans-unit id="ERR_DottedTypeNameNotFoundInNS">
......
...@@ -2653,8 +2653,8 @@ ...@@ -2653,8 +2653,8 @@
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_SizeofUnsafe"> <trans-unit id="ERR_SizeofUnsafe">
<source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)</source> <source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context</source>
<target state="translated">'{0}' n'a pas de taille prédéfinie ; c'est pourquoi sizeof ne peut être utilisé que dans un contexte unsafe (utilisez System.Runtime.InteropServices.Marshal.SizeOf)</target> <target state="needs-review-translation">'{0}' n'a pas de taille prédéfinie ; c'est pourquoi sizeof ne peut être utilisé que dans un contexte unsafe (utilisez System.Runtime.InteropServices.Marshal.SizeOf)</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_DottedTypeNameNotFoundInNS"> <trans-unit id="ERR_DottedTypeNameNotFoundInNS">
......
...@@ -2653,8 +2653,8 @@ ...@@ -2653,8 +2653,8 @@
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_SizeofUnsafe"> <trans-unit id="ERR_SizeofUnsafe">
<source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)</source> <source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context</source>
<target state="translated">'{0}' non ha una dimensione predefinita, quindi sizeof può essere usato solo in un contesto di tipo unsafe. Provare a usare System.Runtime.InteropServices.Marshal.SizeOf</target> <target state="needs-review-translation">'{0}' non ha una dimensione predefinita, quindi sizeof può essere usato solo in un contesto di tipo unsafe. Provare a usare System.Runtime.InteropServices.Marshal.SizeOf</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_DottedTypeNameNotFoundInNS"> <trans-unit id="ERR_DottedTypeNameNotFoundInNS">
......
...@@ -2653,8 +2653,8 @@ ...@@ -2653,8 +2653,8 @@
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_SizeofUnsafe"> <trans-unit id="ERR_SizeofUnsafe">
<source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)</source> <source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context</source>
<target state="translated">'{0}' には定義済みのサイズが指定されていないため、sizeof は unsafe コンテキストでのみ使用できます (System.Runtime.InteropServices.Marshal.SizeOf の使用をお勧めします)</target> <target state="needs-review-translation">'{0}' には定義済みのサイズが指定されていないため、sizeof は unsafe コンテキストでのみ使用できます (System.Runtime.InteropServices.Marshal.SizeOf の使用をお勧めします)</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_DottedTypeNameNotFoundInNS"> <trans-unit id="ERR_DottedTypeNameNotFoundInNS">
......
...@@ -2653,8 +2653,8 @@ ...@@ -2653,8 +2653,8 @@
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_SizeofUnsafe"> <trans-unit id="ERR_SizeofUnsafe">
<source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)</source> <source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context</source>
<target state="translated">'{0}'에 미리 정의된 크기가 없으므로 sizeof는 안전하지 않은 컨텍스트에서만 사용할 수 있습니다. System.Runtime.InteropServices.Marshal.SizeOf를 사용하세요.</target> <target state="needs-review-translation">'{0}'에 미리 정의된 크기가 없으므로 sizeof는 안전하지 않은 컨텍스트에서만 사용할 수 있습니다. System.Runtime.InteropServices.Marshal.SizeOf를 사용하세요.</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_DottedTypeNameNotFoundInNS"> <trans-unit id="ERR_DottedTypeNameNotFoundInNS">
......
...@@ -2653,8 +2653,8 @@ ...@@ -2653,8 +2653,8 @@
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_SizeofUnsafe"> <trans-unit id="ERR_SizeofUnsafe">
<source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)</source> <source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context</source>
<target state="translated">'„{0}” nie ma wstępnie zdefiniowanego rozmiaru, dlatego elementu sizeof można użyć tylko w kontekście słowa kluczowego „unsafe” (użyj elementu System.Runtime.InteropServices.Marshal.SizeOf)</target> <target state="needs-review-translation">'„{0}” nie ma wstępnie zdefiniowanego rozmiaru, dlatego elementu sizeof można użyć tylko w kontekście słowa kluczowego „unsafe” (użyj elementu System.Runtime.InteropServices.Marshal.SizeOf)</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_DottedTypeNameNotFoundInNS"> <trans-unit id="ERR_DottedTypeNameNotFoundInNS">
......
...@@ -2653,8 +2653,8 @@ ...@@ -2653,8 +2653,8 @@
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_SizeofUnsafe"> <trans-unit id="ERR_SizeofUnsafe">
<source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)</source> <source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context</source>
<target state="translated">'"{0}" não tem um tamanho pré-definido; portanto, sizeof só pode ser usado em um contexto desprotegido (considere o uso de System.Runtime.InteropServices.Marshal.SizeOf)</target> <target state="needs-review-translation">'"{0}" não tem um tamanho pré-definido; portanto, sizeof só pode ser usado em um contexto desprotegido (considere o uso de System.Runtime.InteropServices.Marshal.SizeOf)</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_DottedTypeNameNotFoundInNS"> <trans-unit id="ERR_DottedTypeNameNotFoundInNS">
......
...@@ -2653,8 +2653,8 @@ ...@@ -2653,8 +2653,8 @@
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_SizeofUnsafe"> <trans-unit id="ERR_SizeofUnsafe">
<source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)</source> <source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context</source>
<target state="translated">'"{0}" не имеет предопределенного размера, поэтому оператор sizeof может использоваться только в небезопасном (unsafe) контексте (рекомендуется использование System.Runtime.InteropServices.Marshal.SizeOf).</target> <target state="needs-review-translation">'"{0}" не имеет предопределенного размера, поэтому оператор sizeof может использоваться только в небезопасном (unsafe) контексте (рекомендуется использование System.Runtime.InteropServices.Marshal.SizeOf).</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_DottedTypeNameNotFoundInNS"> <trans-unit id="ERR_DottedTypeNameNotFoundInNS">
......
...@@ -2653,8 +2653,8 @@ ...@@ -2653,8 +2653,8 @@
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_SizeofUnsafe"> <trans-unit id="ERR_SizeofUnsafe">
<source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)</source> <source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context</source>
<target state="translated">'{0}' öğesi önceden tanımlı boyuta sahip değil, bu nedenle sizeof yalnızca unsafe bağlamda kullanılabilir (System.Runtime.InteropServices.Marshal.SizeOf kullanmayı düşünün)</target> <target state="needs-review-translation">'{0}' öğesi önceden tanımlı boyuta sahip değil, bu nedenle sizeof yalnızca unsafe bağlamda kullanılabilir (System.Runtime.InteropServices.Marshal.SizeOf kullanmayı düşünün)</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_DottedTypeNameNotFoundInNS"> <trans-unit id="ERR_DottedTypeNameNotFoundInNS">
......
...@@ -2358,8 +2358,8 @@ ...@@ -2358,8 +2358,8 @@
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_SizeofUnsafe"> <trans-unit id="ERR_SizeofUnsafe">
<source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)</source> <source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context</source>
<target state="translated">'“{0}”没有预定义的大小,因此 sizeof 只能在不安全的上下文中使用(请考虑使用 System.Runtime.InteropServices.Marshal.SizeOf)</target> <target state="needs-review-translation">'“{0}”没有预定义的大小,因此 sizeof 只能在不安全的上下文中使用(请考虑使用 System.Runtime.InteropServices.Marshal.SizeOf)</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_DottedTypeNameNotFoundInNS"> <trans-unit id="ERR_DottedTypeNameNotFoundInNS">
......
...@@ -2653,8 +2653,8 @@ ...@@ -2653,8 +2653,8 @@
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_SizeofUnsafe"> <trans-unit id="ERR_SizeofUnsafe">
<source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)</source> <source>'{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context</source>
<target state="translated">'{0}' 沒有預先定義的大小,因此 sizeof 只能使用於 unsafe 內容 (請考慮使用 System.Runtime.InteropServices.Marshal.SizeOf)。</target> <target state="needs-review-translation">'{0}' 沒有預先定義的大小,因此 sizeof 只能使用於 unsafe 內容 (請考慮使用 System.Runtime.InteropServices.Marshal.SizeOf)。</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="ERR_DottedTypeNameNotFoundInNS"> <trans-unit id="ERR_DottedTypeNameNotFoundInNS">
......
...@@ -88,6 +88,20 @@ public override string ToString() ...@@ -88,6 +88,20 @@ public override string ToString()
} }
}"; }";
[Fact, WorkItem(33537, "https://github.com/dotnet/roslyn/issues/33537")]
public void SuppressOnNullLiteralInAs()
{
var comp = CreateCompilation(@"
class C
{
public static void Main()
{
var x = null! as object;
}
}");
comp.VerifyDiagnostics();
}
[Fact, WorkItem(26654, "https://github.com/dotnet/roslyn/issues/26654")] [Fact, WorkItem(26654, "https://github.com/dotnet/roslyn/issues/26654")]
public void SuppressNullableWarning_DeclarationExpression() public void SuppressNullableWarning_DeclarationExpression()
{ {
...@@ -74772,8 +74786,14 @@ public void NullableT_10() ...@@ -74772,8 +74786,14 @@ public void NullableT_10()
} }
}"; }";
var comp = CreateCompilation(source, options: WithNonNullTypesTrue()); var comp = CreateCompilation(source, options: WithNonNullTypesTrue());
// https://github.com/dotnet/roslyn/issues/31502: Recognize Nullable<T> constructors. comp.VerifyDiagnostics(
comp.VerifyDiagnostics(); // (6,13): warning CS8629: Nullable value type may be null.
// _ = x.Value; // 1
Diagnostic(ErrorCode.WRN_NullableValueTypeMayBeNull, "x.Value").WithLocation(6, 13),
// (10,13): warning CS8629: Nullable value type may be null.
// _ = z.Value; // 2
Diagnostic(ErrorCode.WRN_NullableValueTypeMayBeNull, "z.Value").WithLocation(10, 13)
);
} }
[Fact] [Fact]
...@@ -311,7 +311,7 @@ void followBranch(BasicBlockBuilder current, in BasicBlockBuilder.Branch branch) ...@@ -311,7 +311,7 @@ void followBranch(BasicBlockBuilder current, in BasicBlockBuilder.Branch branch)
} }
// Returns whether we should proceed to the destination after finallies were taken care of. // Returns whether we should proceed to the destination after finallies were taken care of.
bool stepThroughFinally(ControlFlowRegion region, BasicBlockBuilder destination) static bool stepThroughFinally(ControlFlowRegion region, BasicBlockBuilder destination)
{ {
int destinationOrdinal = destination.Ordinal; int destinationOrdinal = destination.Ordinal;
while (!region.ContainsBlock(destinationOrdinal)) while (!region.ContainsBlock(destinationOrdinal))
......
...@@ -642,5 +642,46 @@ public C(int i, int hello) ...@@ -642,5 +642,46 @@ public C(int i, int hello)
}" }"
); );
} }
[WorkItem(33602, "https://github.com/dotnet/roslyn/issues/33602")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddConstructorParametersFromMembers)]
public async Task TestConstructorWithNoParameters()
{
await TestInRegularAndScriptAsync(
@"
class C
{
[|int i;
int Hello { get; set; }|]
public C()
{
}
}",
@"
class C
{
int i;
int Hello { get; set; }
public C(int i, int hello)
{
this.i = i;
Hello = hello;
}
}"
);
}
[WorkItem(33602, "https://github.com/dotnet/roslyn/issues/33602")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddConstructorParametersFromMembers)]
public async Task TestDefaultConstructor()
{
await TestMissingAsync(
@"
class C
{
[|int i;|]
int Hello { get; set; }
}");
}
} }
} }
...@@ -202,5 +202,40 @@ Class Program ...@@ -202,5 +202,40 @@ Class Program
End Sub End Sub
End Class") End Class")
End Function End Function
<WorkItem(33602, "https://github.com/dotnet/roslyn/issues/33602")>
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddConstructorParametersFromMembers)>
Public Async Function TestConstructorWithNoParameters() As Task
Await TestInRegularAndScriptAsync(
"
Class Program
[|Private i As Integer
Property Hello As Integer = 1|]
Public Sub New()
End Sub
End Class",
"
Class Program
[|Private i As Integer
Property Hello As Integer = 1|]
Public Sub New(i As Integer, hello As Integer)
Me.i = i
Me.Hello = hello
End Sub
End Class"
)
End Function
<WorkItem(33602, "https://github.com/dotnet/roslyn/issues/33602")>
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddConstructorParametersFromMembers)>
Public Async Function TestDefaultConstructor() As Task
Await TestMissingAsync(
"
Class Program
[|Private i As Integer|]
End Class"
)
End Function
End Class End Class
End Namespace End Namespace
...@@ -77,9 +77,8 @@ private class State ...@@ -77,9 +77,8 @@ private class State
/// <summary> /// <summary>
/// Try to find a constructor in <paramref name="containingType"/> whose parameters is the subset of <paramref name="parameters"/> by comparing name. /// Try to find a constructor in <paramref name="containingType"/> whose parameters is the subset of <paramref name="parameters"/> by comparing name.
/// If multiple constructors meet the condition, the one with more parameters will be returned. /// If multiple constructors meet the condition, the one with more parameters will be returned.
/// It will not consider those constructors as potential candidates if: /// It will not consider those constructors as potential candidates if the constructor's parameter list
/// 1. Constructor with empty parameter list. /// contains 'ref' or 'params'
/// 2. Constructor's parameter list contains 'ref' or 'params'
/// </summary> /// </summary>
private IMethodSymbol GetDelegatedConstructorBasedOnParameterNames( private IMethodSymbol GetDelegatedConstructorBasedOnParameterNames(
INamedTypeSymbol containingType, INamedTypeSymbol containingType,
...@@ -87,18 +86,22 @@ private class State ...@@ -87,18 +86,22 @@ private class State
{ {
var parameterNames = parameters.SelectAsArray(p => p.Name); var parameterNames = parameters.SelectAsArray(p => p.Name);
return containingType.InstanceConstructors return containingType.InstanceConstructors
.Where(constructor => AreParametersContainedInConstructor(constructor, parameterNames)) .Where(constructor => IsApplicableConstructor(constructor, parameterNames))
.OrderByDescending(constructor => constructor.Parameters.Length) .OrderByDescending(constructor => constructor.Parameters.Length)
.FirstOrDefault(); .FirstOrDefault();
} }
private bool AreParametersContainedInConstructor( private bool IsApplicableConstructor(
IMethodSymbol constructor, IMethodSymbol constructor,
ImmutableArray<string> parametersName) ImmutableArray<string> parametersName)
{ {
var constructorParams = constructor.Parameters; var constructorParams = constructor.Parameters;
return constructorParams.Length > 0 if (constructorParams.Length == 0)
&& constructorParams.All(parameter => parameter.RefKind == RefKind.None) {
return !constructor.IsImplicitlyDeclared;
}
return constructorParams.All(parameter => parameter.RefKind == RefKind.None)
&& !constructorParams.Any(p => p.IsParams) && !constructorParams.Any(p => p.IsParams)
&& parametersName.Except(constructorParams.Select(p => p.Name)).Any(); && parametersName.Except(constructorParams.Select(p => p.Name)).Any();
} }
......
...@@ -56,9 +56,11 @@ public async Task<ImmutableArray<CodeAction>> AddConstructorParametersFromMember ...@@ -56,9 +56,11 @@ public async Task<ImmutableArray<CodeAction>> AddConstructorParametersFromMember
private IEnumerable<CodeAction> CreateCodeActions(Document document, State state) private IEnumerable<CodeAction> CreateCodeActions(Document document, State state)
{ {
var lastParameter = state.ConstructorToAddTo.Parameters.Last(); var parameters = state.ConstructorToAddTo.Parameters;
if (!lastParameter.IsOptional) if (parameters.Length == 0 ||
(parameters.Length > 0 && !parameters.Last().IsOptional))
{ {
// return a code action to add required parameters
yield return new AddConstructorParametersCodeAction(this, document, state, state.MissingParameters); yield return new AddConstructorParametersCodeAction(this, document, state, state.MissingParameters);
} }
...@@ -71,6 +73,7 @@ private IEnumerable<CodeAction> CreateCodeActions(Document document, State state ...@@ -71,6 +73,7 @@ private IEnumerable<CodeAction> CreateCodeActions(Document document, State state
isOptional: true, isOptional: true,
hasDefaultValue: true)); hasDefaultValue: true));
// return a code action to add optional parameters
yield return new AddConstructorParametersCodeAction(this, document, state, missingParameters); yield return new AddConstructorParametersCodeAction(this, document, state, missingParameters);
} }
} }
......
...@@ -92,6 +92,19 @@ public VisualStudioInstance(Process hostProcess, DTE dte, ImmutableHashSet<strin ...@@ -92,6 +92,19 @@ public VisualStudioInstance(Process hostProcess, DTE dte, ImmutableHashSet<strin
SupportedPackageIds = supportedPackageIds; SupportedPackageIds = supportedPackageIds;
InstallationPath = installationPath; InstallationPath = installationPath;
if (System.Diagnostics.Debugger.IsAttached)
{
// If a Visual Studio debugger is attached to the test process, attach it to the instance running
// integration tests as well.
var debuggerHostDte = GetDebuggerHostDte();
int targetProcessId = Process.GetCurrentProcess().Id;
var localProcess = debuggerHostDte?.Debugger.LocalProcesses.OfType<EnvDTE80.Process2>().FirstOrDefault(p => p.ProcessID == hostProcess.Id);
if (localProcess != null)
{
localProcess.Attach2("Managed");
}
}
StartRemoteIntegrationService(dte); StartRemoteIntegrationService(dte);
_integrationServiceChannel = new IpcClientChannel(GetIpcClientChannelName(HostProcess), sinkProvider: null); _integrationServiceChannel = new IpcClientChannel(GetIpcClientChannelName(HostProcess), sinkProvider: null);
...@@ -239,6 +252,21 @@ public void Close(bool exitHostProcess = true) ...@@ -239,6 +252,21 @@ public void Close(bool exitHostProcess = true)
} }
} }
private static DTE GetDebuggerHostDte()
{
var currentProcessId = Process.GetCurrentProcess().Id;
foreach (var process in Process.GetProcessesByName("devenv"))
{
var dte = IntegrationHelper.TryLocateDteForProcess(process);
if (dte?.Debugger?.DebuggedProcesses?.OfType<EnvDTE.Process>().Any(p => p.ProcessID == currentProcessId) ?? false)
{
return dte;
}
}
return null;
}
private void CloseHostProcess() private void CloseHostProcess()
{ {
_inProc.Quit(); _inProc.Quit();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册