提交 b6501814 编写于 作者: T Tanner Gooding

Merge remote-tracking branch 'dotnet/master' into features/test-impact

......@@ -125,13 +125,17 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Metadata", "src\Dependencie
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "xUnit.net", "src\Dependencies\xUnit.net\xUnit.net.csproj", "{8635CB8F-D210-41ED-B4FF-71502CDB475C}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.CodeAnalysis.PooledObjects", "src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.shproj", "{CD77A8CC-2885-47A7-B99C-FBF13353400B}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.CodeAnalysis.Metadata", "src\Dependencies\CodeAnalysis.Metadata\Microsoft.CodeAnalysis.Metadata.shproj", "{D73ADF7D-2C1C-42AE-B2AB-EDC9497E4B71}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Compilers\Core\CommandLine\CommandLine.projitems*{06b26dcb-7a12-48ef-ae50-708593abd05f}*SharedItemsImports = 4
src\Compilers\Server\ServerShared\ServerShared.projitems*{06b26dcb-7a12-48ef-ae50-708593abd05f}*SharedItemsImports = 4
src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
src\Compilers\Core\SharedCollections\SharedCollections.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
src\Compilers\Metadata\Microsoft.CodeAnalysis.Metadata.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
src\Dependencies\CodeAnalysis.Metadata\Microsoft.CodeAnalysis.Metadata.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{2523d0e6-df32-4a3e-8ae0-a19bffae2ef6}*SharedItemsImports = 4
src\Compilers\Server\ServerShared\ServerShared.projitems*{32691768-af9c-4cae-9d0f-10721091b9aa}*SharedItemsImports = 13
src\Compilers\Core\CommandLine\CommandLine.projitems*{4b45ca0c-03a0-400f-b454-3d4bcb16af38}*SharedItemsImports = 4
......@@ -143,12 +147,14 @@ Global
src\Compilers\Core\CommandLine\CommandLine.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 4
src\Compilers\Server\ServerShared\ServerShared.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{ad6f474e-e6d4-4217-91f3-b7af1be31ccc}*SharedItemsImports = 13
src\Compilers\Core\SharedCollections\SharedCollections.projitems*{afde6bea-5038-4a4a-a88e-dbd2e4088eed}*SharedItemsImports = 4
src\Compilers\Metadata\Microsoft.CodeAnalysis.Metadata.projitems*{afde6bea-5038-4a4a-a88e-dbd2e4088eed}*SharedItemsImports = 4
src\Dependencies\CodeAnalysis.Metadata\Microsoft.CodeAnalysis.Metadata.projitems*{afde6bea-5038-4a4a-a88e-dbd2e4088eed}*SharedItemsImports = 4
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{afde6bea-5038-4a4a-a88e-dbd2e4088eed}*SharedItemsImports = 4
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{b501a547-c911-4a05-ac6e-274a50dff30e}*SharedItemsImports = 4
src\Compilers\Core\SharedCollections\SharedCollections.projitems*{c1930979-c824-496b-a630-70f5369a636f}*SharedItemsImports = 13
src\Test\Utilities\Shared\TestUtilities.projitems*{ccbd3438-3e84-40a9-83ad-533f23bcfca5}*SharedItemsImports = 4
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{cd77a8cc-2885-47a7-b99c-fbf13353400b}*SharedItemsImports = 13
src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{d0bc9be7-24f6-40ca-8dc6-fcb93bd44b34}*SharedItemsImports = 13
src\Dependencies\CodeAnalysis.Metadata\Microsoft.CodeAnalysis.Metadata.projitems*{d73adf7d-2c1c-42ae-b2ab-edc9497e4b71}*SharedItemsImports = 13
src\Compilers\Core\CommandLine\CommandLine.projitems*{d874349c-8bb3-4bdc-8535-2d52ccca1198}*SharedItemsImports = 4
src\Compilers\Core\MSBuildTask\Shared\MSBuildTask.Shared.projitems*{d874349c-8bb3-4bdc-8535-2d52ccca1198}*SharedItemsImports = 4
src\Compilers\Core\MSBuildTask\Shared\MSBuildTask.Shared.projitems*{d87f0e46-dd1b-46ea-8425-9e185d9b602e}*SharedItemsImports = 13
......@@ -1159,5 +1165,7 @@ Global
{DCDA908D-EF5E-494B-ADDC-C26F5FD610CA} = {3CDEA9FB-CD44-4AB4-98A8-5537AAA2169B}
{E6796B97-D5C6-45B2-AE46-351D15DCFC71} = {3CDEA9FB-CD44-4AB4-98A8-5537AAA2169B}
{8635CB8F-D210-41ED-B4FF-71502CDB475C} = {3CDEA9FB-CD44-4AB4-98A8-5537AAA2169B}
{CD77A8CC-2885-47A7-B99C-FBF13353400B} = {3CDEA9FB-CD44-4AB4-98A8-5537AAA2169B}
{D73ADF7D-2C1C-42AE-B2AB-EDC9497E4B71} = {3CDEA9FB-CD44-4AB4-98A8-5537AAA2169B}
EndGlobalSection
EndGlobal
......@@ -47,8 +47,6 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "BasicWorkspace", "src\Works
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "AnalyzerDriver", "src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.shproj", "{D0BC9BE7-24F6-40CA-8DC6-FCB93BD44B34}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SharedCollections", "src\Compilers\Core\SharedCollections\SharedCollections.shproj", "{C1930979-C824-496B-A630-70F5369A636F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CscCore", "src\Compilers\CSharp\CscCore\CscCore.csproj", "{E3CD2895-76A8-4D11-A316-EA67CB5EA42C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VbcCore", "src\Compilers\VisualBasic\VbcCore\VbcCore.csproj", "{8CE3A581-2969-4864-A803-013E9D977C3A}"
......@@ -95,20 +93,27 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiaSymReader", "src\Depende
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Composition", "src\Dependencies\Composition\Composition.csproj", "{A57DDFE5-AB0E-4371-98E5-11B9218DF11C}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.CodeAnalysis.Metadata", "src\Dependencies\CodeAnalysis.Metadata\Microsoft.CodeAnalysis.Metadata.shproj", "{D73ADF7D-2C1C-42AE-B2AB-EDC9497E4B71}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.CodeAnalysis.PooledObjects", "src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.shproj", "{DEEC46EB-89AD-4C09-AC0A-B296456E2DC7}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
src\Compilers\Core\SharedCollections\SharedCollections.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
src\Dependencies\CodeAnalysis.Metadata\Microsoft.CodeAnalysis.Metadata.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{2523d0e6-df32-4a3e-8ae0-a19bffae2ef6}*SharedItemsImports = 4
src\Compilers\Core\SharedCollections\SharedCollections.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 4
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 4
src\Test\Utilities\Shared\TestUtilities.projitems*{6ff42825-5464-4151-ac55-ed828168c192}*SharedItemsImports = 13
src\Compilers\Core\CommandLine\CommandLine.projitems*{8ce3a581-2969-4864-a803-013e9d977c3a}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{ad6f474e-e6d4-4217-91f3-b7af1be31ccc}*SharedItemsImports = 13
src\Compilers\Core\SharedCollections\SharedCollections.projitems*{afde6bea-5038-4a4a-a88e-dbd2e4088eed}*SharedItemsImports = 4
src\Dependencies\CodeAnalysis.Metadata\Microsoft.CodeAnalysis.Metadata.projitems*{afde6bea-5038-4a4a-a88e-dbd2e4088eed}*SharedItemsImports = 4
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{afde6bea-5038-4a4a-a88e-dbd2e4088eed}*SharedItemsImports = 4
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{b501a547-c911-4a05-ac6e-274a50dff30e}*SharedItemsImports = 4
src\Compilers\Core\SharedCollections\SharedCollections.projitems*{c1930979-c824-496b-a630-70f5369a636f}*SharedItemsImports = 13
src\Test\Utilities\Shared\TestUtilities.projitems*{ccbd3438-3e84-40a9-83ad-533f23bcfca5}*SharedItemsImports = 4
src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{d0bc9be7-24f6-40ca-8dc6-fcb93bd44b34}*SharedItemsImports = 13
src\Dependencies\CodeAnalysis.Metadata\Microsoft.CodeAnalysis.Metadata.projitems*{d73adf7d-2c1c-42ae-b2ab-edc9497e4b71}*SharedItemsImports = 13
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{deec46eb-89ad-4c09-ac0a-b296456e2dc7}*SharedItemsImports = 13
src\Compilers\Core\CommandLine\CommandLine.projitems*{e3cd2895-76a8-4d11-a316-ea67cb5ea42c}*SharedItemsImports = 4
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......@@ -790,7 +795,6 @@ Global
{21B239D0-D144-430F-A394-C066D58EE267} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5}
{57CA988D-F010-4BF2-9A2E-07D6DCD2FF2C} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5}
{D0BC9BE7-24F6-40CA-8DC6-FCB93BD44B34} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9}
{C1930979-C824-496B-A630-70F5369A636F} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9}
{E3CD2895-76A8-4D11-A316-EA67CB5EA42C} = {32A48625-F0AD-419D-828B-A50BDABA38EA}
{8CE3A581-2969-4864-A803-013E9D977C3A} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37}
{6FF42825-5464-4151-AC55-ED828168C192} = {50509463-6012-4061-99BF-6C5C8262E643}
......@@ -811,5 +815,7 @@ Global
{E6796B97-D5C6-45B2-AE46-351D15DCFC71} = {A18BACE1-BB66-4156-8E89-81429A5814C6}
{D2B8B03E-A85D-48A2-818F-9177D89586A9} = {A18BACE1-BB66-4156-8E89-81429A5814C6}
{A57DDFE5-AB0E-4371-98E5-11B9218DF11C} = {A18BACE1-BB66-4156-8E89-81429A5814C6}
{D73ADF7D-2C1C-42AE-B2AB-EDC9497E4B71} = {A18BACE1-BB66-4156-8E89-81429A5814C6}
{DEEC46EB-89AD-4C09-AC0A-B296456E2DC7} = {A18BACE1-BB66-4156-8E89-81429A5814C6}
EndGlobalSection
EndGlobal
......@@ -228,8 +228,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{998CAFE8-0
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "AnalyzerDriver", "src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.shproj", "{D0BC9BE7-24F6-40CA-8DC6-FCB93BD44B34}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SharedCollections", "src\Compilers\Core\SharedCollections\SharedCollections.shproj", "{C1930979-C824-496B-A630-70F5369A636F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpWinRTTest", "src\Compilers\CSharp\Test\WinRT\CSharpWinRTTest.csproj", "{FCFA8808-A1B6-48CC-A1EA-0B8CA8AEDA8E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSBuildTaskTests", "src\Compilers\Core\MSBuildTaskTests\MSBuildTaskTests.csproj", "{1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}"
......@@ -372,15 +370,17 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiaSymReader.PortablePdb",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SignRoslyn", "src\Tools\SignRoslyn\SignRoslyn.csproj", "{3DA711E1-055F-4352-A5E1-F9169C86A20F}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.CodeAnalysis.Metadata", "src\Compilers\Metadata\Microsoft.CodeAnalysis.Metadata.shproj", "{D73ADF7D-2C1C-42AE-B2AB-EDC9497E4B71}"
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.CodeAnalysis.Metadata", "src\Dependencies\CodeAnalysis.Metadata\Microsoft.CodeAnalysis.Metadata.shproj", "{D73ADF7D-2C1C-42AE-B2AB-EDC9497E4B71}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.CodeAnalysis.PooledObjects", "src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.shproj", "{C1930979-C824-496B-A630-70F5369A636F}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Compilers\Core\CommandLine\CommandLine.projitems*{06b26dcb-7a12-48ef-ae50-708593abd05f}*SharedItemsImports = 4
src\Compilers\Server\ServerShared\ServerShared.projitems*{06b26dcb-7a12-48ef-ae50-708593abd05f}*SharedItemsImports = 4
src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
src\Compilers\Core\SharedCollections\SharedCollections.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
src\Compilers\Metadata\Microsoft.CodeAnalysis.Metadata.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
src\Dependencies\CodeAnalysis.Metadata\Microsoft.CodeAnalysis.Metadata.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{2523d0e6-df32-4a3e-8ae0-a19bffae2ef6}*SharedItemsImports = 4
src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.projitems*{3140fe61-0856-4367-9aa3-8081b9a80e35}*SharedItemsImports = 13
src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.projitems*{3140fe61-0856-4367-9aa3-8081b9a80e36}*SharedItemsImports = 13
......@@ -388,7 +388,7 @@ Global
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{3973b09a-4fbf-44a5-8359-3d22ceb71f71}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{4b45ca0c-03a0-400f-b454-3d4bcb16af38}*SharedItemsImports = 4
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{54e08bf5-f819-404f-a18d-0ab9ea81ea04}*SharedItemsImports = 13
src\Compilers\Core\SharedCollections\SharedCollections.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 4
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 4
src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.projitems*{60db272a-21c9-4e8d-9803-ff4e132392c8}*SharedItemsImports = 4
src\Test\Utilities\Shared\TestUtilities.projitems*{6ff42825-5464-4151-ac55-ed828168c192}*SharedItemsImports = 13
src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.projitems*{76242a2d-2600-49dd-8c15-fea07ecb1842}*SharedItemsImports = 4
......@@ -396,7 +396,7 @@ Global
src\Test\Utilities\Shared\TestUtilities.projitems*{76c6f005-c89d-4348-bb4a-391898dbeb52}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{7ad4fe65-9a30-41a6-8004-aa8f89bcb7f3}*SharedItemsImports = 4
src\Compilers\Core\MSBuildTask\Shared\MSBuildTask.Shared.projitems*{7ad4fe65-9a30-41a6-8004-aa8f89bcb7f3}*SharedItemsImports = 4
src\Compilers\Metadata\Microsoft.CodeAnalysis.Metadata.projitems*{86fd5b9a-4fa0-4b10-b59f-cfaf077a859c}*SharedItemsImports = 4
src\Dependencies\CodeAnalysis.Metadata\Microsoft.CodeAnalysis.Metadata.projitems*{86fd5b9a-4fa0-4b10-b59f-cfaf077a859c}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{8ce3a581-2969-4864-a803-013e9d977c3a}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 4
src\Compilers\Server\ServerShared\ServerShared.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 4
......@@ -404,17 +404,17 @@ Global
src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.projitems*{abdbac1e-350e-4dc3-bb45-3504404545ee}*SharedItemsImports = 4
src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.projitems*{ace53515-482c-4c6a-e2d2-4242a687dfee}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{ad6f474e-e6d4-4217-91f3-b7af1be31ccc}*SharedItemsImports = 13
src\Compilers\Core\SharedCollections\SharedCollections.projitems*{afde6bea-5038-4a4a-a88e-dbd2e4088eed}*SharedItemsImports = 4
src\Compilers\Metadata\Microsoft.CodeAnalysis.Metadata.projitems*{afde6bea-5038-4a4a-a88e-dbd2e4088eed}*SharedItemsImports = 4
src\Dependencies\CodeAnalysis.Metadata\Microsoft.CodeAnalysis.Metadata.projitems*{afde6bea-5038-4a4a-a88e-dbd2e4088eed}*SharedItemsImports = 4
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{afde6bea-5038-4a4a-a88e-dbd2e4088eed}*SharedItemsImports = 4
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{b501a547-c911-4a05-ac6e-274a50dff30e}*SharedItemsImports = 4
src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.projitems*{bb3ca047-5d00-48d4-b7d3-233c1265c065}*SharedItemsImports = 13
src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.projitems*{bedc5a4a-809e-4017-9cfd-6c8d4e1847f0}*SharedItemsImports = 4
src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.projitems*{bf9dac1e-3a5e-4dc3-bb44-9a64e0d4e9d3}*SharedItemsImports = 4
src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.projitems*{bf9dac1e-3a5e-4dc3-bb44-9a64e0d4e9d4}*SharedItemsImports = 4
src\Compilers\Core\SharedCollections\SharedCollections.projitems*{c1930979-c824-496b-a630-70f5369a636f}*SharedItemsImports = 13
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{c1930979-c824-496b-a630-70f5369a636f}*SharedItemsImports = 13
src\Test\Utilities\Shared\TestUtilities.projitems*{ccbd3438-3e84-40a9-83ad-533f23bcfca5}*SharedItemsImports = 4
src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{d0bc9be7-24f6-40ca-8dc6-fcb93bd44b34}*SharedItemsImports = 13
src\Compilers\Metadata\Microsoft.CodeAnalysis.Metadata.projitems*{d73adf7d-2c1c-42ae-b2ab-edc9497e4b71}*SharedItemsImports = 13
src\Dependencies\CodeAnalysis.Metadata\Microsoft.CodeAnalysis.Metadata.projitems*{d73adf7d-2c1c-42ae-b2ab-edc9497e4b71}*SharedItemsImports = 13
src\Compilers\Core\CommandLine\CommandLine.projitems*{d874349c-8bb3-4bdc-8535-2d52ccca1198}*SharedItemsImports = 4
src\Compilers\Core\MSBuildTask\Shared\MSBuildTask.Shared.projitems*{d874349c-8bb3-4bdc-8535-2d52ccca1198}*SharedItemsImports = 4
src\Compilers\Core\MSBuildTask\Shared\MSBuildTask.Shared.projitems*{d87f0e46-dd1b-46ea-8425-9e185d9b602e}*SharedItemsImports = 13
......@@ -3309,7 +3309,6 @@ Global
{4C81EBB2-82E1-4C81-80C4-84CC40FA281B} = {235A3418-A3B0-4844-BCEB-F1CF45069232}
{998CAFE8-06E4-4683-A151-0F6AA4BFF6C6} = {235A3418-A3B0-4844-BCEB-F1CF45069232}
{D0BC9BE7-24F6-40CA-8DC6-FCB93BD44B34} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9}
{C1930979-C824-496B-A630-70F5369A636F} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9}
{FCFA8808-A1B6-48CC-A1EA-0B8CA8AEDA8E} = {32A48625-F0AD-419D-828B-A50BDABA38EA}
{1DFEA9C5-973C-4179-9B1B-0F32288E1EF2} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9}
{3140FE61-0856-4367-9AA3-8081B9A80E35} = {151F6994-AEB3-4B12-B746-2ACFF26C7BBB}
......@@ -3375,6 +3374,7 @@ Global
{1AA6D2F0-2C40-4AF6-BB79-50AFDCC62720} = {DD13507E-D5AF-4B61-B11A-D55D6F4A73A5}
{D06F8190-AC11-48E6-B0BF-5F17B7EB7B62} = {C2D1346B-9665-4150-B644-075CF1636BAA}
{3DA711E1-055F-4352-A5E1-F9169C86A20F} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC}
{D73ADF7D-2C1C-42AE-B2AB-EDC9497E4B71} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9}
{D73ADF7D-2C1C-42AE-B2AB-EDC9497E4B71} = {C2D1346B-9665-4150-B644-075CF1636BAA}
{C1930979-C824-496B-A630-70F5369A636F} = {C2D1346B-9665-4150-B644-075CF1636BAA}
EndGlobalSection
EndGlobal
......@@ -37,8 +37,6 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VisualBasicErrorFactsGenera
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "AnalyzerDriver", "..\src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.shproj", "{D0BC9BE7-24F6-40CA-8DC6-FCB93BD44B34}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SharedCollections", "..\src\Compilers\Core\SharedCollections\SharedCollections.shproj", "{C1930979-C824-496B-A630-70F5369A636F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csc", "..\src\Compilers\CSharp\csc\csc.csproj", "{4B45CA0C-03A0-400F-B454-3D4BCB16AF38}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vbc", "..\src\Compilers\VisualBasic\vbc\vbc.csproj", "{E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}"
......@@ -51,16 +49,25 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "MSBuildTask.Shared", "..\sr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeployCompilerGeneratorToolsRuntime", "..\src\Tools\Source\CompilerGeneratorTools\DeployCompilerGeneratorToolsRuntime\DeployCompilerGeneratorToolsRuntime.csproj", "{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependencies", "Dependencies", "{4BCF8873-A442-4BDA-87D1-4772E4A8A650}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.CodeAnalysis.PooledObjects", "..\src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.shproj", "{C1930979-C824-496B-A630-70F5369A636F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Immutable", "..\src\Dependencies\Immutable\Immutable.csproj", "{DCDA908D-EF5E-494B-ADDC-C26F5FD610CA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Metadata", "..\src\Dependencies\Metadata\Metadata.csproj", "{E6796B97-D5C6-45B2-AE46-351D15DCFC71}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
..\src\Compilers\Core\SharedCollections\SharedCollections.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
..\src\Dependencies\CodeAnalysis.Metadata\Microsoft.CodeAnalysis.Metadata.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
..\src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
..\src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{2523d0e6-df32-4a3e-8ae0-a19bffae2ef6}*SharedItemsImports = 4
..\src\Compilers\Core\CommandLine\CommandLine.projitems*{4b45ca0c-03a0-400f-b454-3d4bcb16af38}*SharedItemsImports = 4
..\src\Compilers\Core\CommandLine\CommandLine.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 4
..\src\Compilers\Server\ServerShared\ServerShared.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 4
..\src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{b501a547-c911-4a05-ac6e-274a50dff30e}*SharedItemsImports = 4
..\src\Compilers\Core\SharedCollections\SharedCollections.projitems*{c1930979-c824-496b-a630-70f5369a636f}*SharedItemsImports = 13
..\src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{c1930979-c824-496b-a630-70f5369a636f}*SharedItemsImports = 13
..\src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{d0bc9be7-24f6-40ca-8dc6-fcb93bd44b34}*SharedItemsImports = 13
..\src\Compilers\Core\CommandLine\CommandLine.projitems*{d874349c-8bb3-4bdc-8535-2d52ccca1198}*SharedItemsImports = 4
..\src\Compilers\Core\MSBuildTask\Shared\MSBuildTask.Shared.projitems*{d874349c-8bb3-4bdc-8535-2d52ccca1198}*SharedItemsImports = 4
......@@ -286,6 +293,38 @@ Global
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Release|x64.ActiveCfg = Release|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Release|x64.Build.0 = Release|Any CPU
{DCDA908D-EF5E-494B-ADDC-C26F5FD610CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DCDA908D-EF5E-494B-ADDC-C26F5FD610CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DCDA908D-EF5E-494B-ADDC-C26F5FD610CA}.Debug|ARM.ActiveCfg = Debug|Any CPU
{DCDA908D-EF5E-494B-ADDC-C26F5FD610CA}.Debug|ARM.Build.0 = Debug|Any CPU
{DCDA908D-EF5E-494B-ADDC-C26F5FD610CA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{DCDA908D-EF5E-494B-ADDC-C26F5FD610CA}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{DCDA908D-EF5E-494B-ADDC-C26F5FD610CA}.Debug|x64.ActiveCfg = Debug|Any CPU
{DCDA908D-EF5E-494B-ADDC-C26F5FD610CA}.Debug|x64.Build.0 = Debug|Any CPU
{DCDA908D-EF5E-494B-ADDC-C26F5FD610CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DCDA908D-EF5E-494B-ADDC-C26F5FD610CA}.Release|Any CPU.Build.0 = Release|Any CPU
{DCDA908D-EF5E-494B-ADDC-C26F5FD610CA}.Release|ARM.ActiveCfg = Release|Any CPU
{DCDA908D-EF5E-494B-ADDC-C26F5FD610CA}.Release|ARM.Build.0 = Release|Any CPU
{DCDA908D-EF5E-494B-ADDC-C26F5FD610CA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{DCDA908D-EF5E-494B-ADDC-C26F5FD610CA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{DCDA908D-EF5E-494B-ADDC-C26F5FD610CA}.Release|x64.ActiveCfg = Release|Any CPU
{DCDA908D-EF5E-494B-ADDC-C26F5FD610CA}.Release|x64.Build.0 = Release|Any CPU
{E6796B97-D5C6-45B2-AE46-351D15DCFC71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E6796B97-D5C6-45B2-AE46-351D15DCFC71}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E6796B97-D5C6-45B2-AE46-351D15DCFC71}.Debug|ARM.ActiveCfg = Debug|Any CPU
{E6796B97-D5C6-45B2-AE46-351D15DCFC71}.Debug|ARM.Build.0 = Debug|Any CPU
{E6796B97-D5C6-45B2-AE46-351D15DCFC71}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{E6796B97-D5C6-45B2-AE46-351D15DCFC71}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{E6796B97-D5C6-45B2-AE46-351D15DCFC71}.Debug|x64.ActiveCfg = Debug|Any CPU
{E6796B97-D5C6-45B2-AE46-351D15DCFC71}.Debug|x64.Build.0 = Debug|Any CPU
{E6796B97-D5C6-45B2-AE46-351D15DCFC71}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E6796B97-D5C6-45B2-AE46-351D15DCFC71}.Release|Any CPU.Build.0 = Release|Any CPU
{E6796B97-D5C6-45B2-AE46-351D15DCFC71}.Release|ARM.ActiveCfg = Release|Any CPU
{E6796B97-D5C6-45B2-AE46-351D15DCFC71}.Release|ARM.Build.0 = Release|Any CPU
{E6796B97-D5C6-45B2-AE46-351D15DCFC71}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{E6796B97-D5C6-45B2-AE46-351D15DCFC71}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{E6796B97-D5C6-45B2-AE46-351D15DCFC71}.Release|x64.ActiveCfg = Release|Any CPU
{E6796B97-D5C6-45B2-AE46-351D15DCFC71}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......@@ -303,12 +342,14 @@ Global
{6AA96934-D6B7-4CC8-990D-DB6B9DD56E34} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC}
{909B656F-6095-4AC2-A5AB-C3F032315C45} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC}
{D0BC9BE7-24F6-40CA-8DC6-FCB93BD44B34} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9}
{C1930979-C824-496B-A630-70F5369A636F} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9}
{4B45CA0C-03A0-400F-B454-3D4BCB16AF38} = {32A48625-F0AD-419D-828B-A50BDABA38EA}
{E58EE9D7-1239-4961-A0C1-F9EC3952C4C1} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37}
{9508F118-F62E-4C16-A6F4-7C3B56E166AD} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9}
{D874349C-8BB3-4BDC-8535-2D52CCCA1198} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9}
{D87F0E46-DD1B-46EA-8425-9E185D9B602E} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9}
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC}
{C1930979-C824-496B-A630-70F5369A636F} = {4BCF8873-A442-4BDA-87D1-4772E4A8A650}
{DCDA908D-EF5E-494B-ADDC-C26F5FD610CA} = {4BCF8873-A442-4BDA-87D1-4772E4A8A650}
{E6796B97-D5C6-45B2-AE46-351D15DCFC71} = {4BCF8873-A442-4BDA-87D1-4772E4A8A650}
EndGlobalSection
EndGlobal
......@@ -62,7 +62,7 @@ private BoundDeconstructionAssignmentOperator BindDeconstructionAssignment(CShar
// For declarations, that means merging type information from the LHS and RHS
// For assignments, only the LHS side matters since it is necessarily typed
TypeSymbol lhsAsTuple = MakeMergedTupleType(checkedVariables, (BoundTupleLiteral)boundRHS, node, Compilation, diagnostics);
if (lhsAsTuple != null)
if ((object)lhsAsTuple != null)
{
boundRHS = GenerateConversionForAssignment(lhsAsTuple, boundRHS, diagnostics);
}
......@@ -299,7 +299,7 @@ private static TypeSymbol MakeMergedTupleType(ArrayBuilder<DeconstructionVariabl
int leftLength = lhsVariables.Count;
int rightLength = rhsLiteral.Arguments.Length;
var typesBuilder = ArrayBuilder<TypeSymbol>.GetInstance(lhsVariables.Count);
var typesBuilder = ArrayBuilder<TypeSymbol>.GetInstance(leftLength);
for (int i = 0; i < rightLength; i++)
{
BoundExpression element = rhsLiteral.Arguments[i];
......
......@@ -463,6 +463,7 @@ private TypeSymbol BindTupleType(TupleTypeSyntax syntax, DiagnosticBag diagnosti
if (typesArray.Length < 2)
{
elementNames?.Free();
return new ExtendedErrorTypeSymbol(this.Compilation.Assembly.GlobalNamespace, LookupResultKind.NotCreatable, diagnostics.Add(ErrorCode.ERR_TupleTooFewElements, syntax.Location));
}
......@@ -500,7 +501,7 @@ private static void CollectTupleFieldMemberNames(string name, int position, int
}
}
private static bool CheckTupleMemberName(string name, int position, CSharpSyntaxNode syntax, DiagnosticBag diagnostics, PooledHashSet<string> uniqueFieldNames)
private static bool CheckTupleMemberName(string name, int index, CSharpSyntaxNode syntax, DiagnosticBag diagnostics, PooledHashSet<string> uniqueFieldNames)
{
int reserved = TupleTypeSymbol.IsElementNameReserved(name);
if (reserved == 0)
......@@ -508,7 +509,7 @@ private static bool CheckTupleMemberName(string name, int position, CSharpSyntax
Error(diagnostics, ErrorCode.ERR_TupleReservedMemberNameAnyPosition, syntax, name);
return false;
}
else if (reserved > 0 && reserved != position + 1)
else if (reserved > 0 && reserved != index + 1)
{
Error(diagnostics, ErrorCode.ERR_TupleReservedMemberName, syntax, name, reserved);
return false;
......
......@@ -444,17 +444,14 @@ private void AddTupleTypeName(INamedTypeSymbol symbol)
AddPunctuation(SyntaxKind.OpenParenToken);
bool first = true;
for (int i = 0; i < elementTypes.Length; i++)
{
if (!first)
if (i != 0)
{
AddPunctuation(SyntaxKind.CommaToken);
AddSpace();
}
first = false;
elementTypes[i].Accept(this.NotFirstVisitor);
if (hasNames && elementNames[i] != null)
{
......
......@@ -54,7 +54,6 @@ private TupleTypeSymbol(Location locationOpt, NamedTypeSymbol underlyingType, Im
private TupleTypeSymbol(ImmutableArray<Location> locations, NamedTypeSymbol underlyingType, ImmutableArray<Location> elementLocations, ImmutableArray<string> elementNames, ImmutableArray<TypeSymbol> elementTypes)
: base(underlyingType)
{
Debug.Assert(elementLocations.IsDefault || elementNames.IsDefault || elementLocations.Length == elementNames.Length);
Debug.Assert(elementLocations.IsDefault || elementLocations.Length == elementTypes.Length);
Debug.Assert(elementNames.IsDefault || elementNames.Length == elementTypes.Length);
Debug.Assert(!underlyingType.IsTupleType);
......@@ -186,29 +185,20 @@ private static NamedTypeSymbol ReplaceRestExtensionType(NamedTypeSymbol tupleCom
for (int i = 0; i < RestPosition - 1; i++)
{
if (!modifiers.IsDefault && !modifiers[i].IsDefaultOrEmpty)
{
typeArgumentsBuilder.Add(new TypeWithModifiers(arguments[i], modifiers[i]));
}
else
{
typeArgumentsBuilder.Add(new TypeWithModifiers(arguments[i]));
}
typeArgumentsBuilder.Add(new TypeWithModifiers(arguments[i], GetModifiers(modifiers, i)));
}
if (!modifiers.IsDefault && !modifiers[RestPosition - 1].IsDefaultOrEmpty)
{
typeArgumentsBuilder.Add(new TypeWithModifiers(extensionTuple, modifiers[RestPosition - 1]));
}
else
{
typeArgumentsBuilder.Add(new TypeWithModifiers(extensionTuple));
}
typeArgumentsBuilder.Add(new TypeWithModifiers(extensionTuple, GetModifiers(modifiers, RestPosition - 1)));
tupleCompatibleType = tupleCompatibleType.ConstructedFrom.Construct(typeArgumentsBuilder.ToImmutable(), unbound: false);
return tupleCompatibleType;
}
private static ImmutableArray<CustomModifier> GetModifiers(ImmutableArray<ImmutableArray<CustomModifier>> modifiers, int i)
{
return modifiers.IsDefaultOrEmpty? ImmutableArray<CustomModifier>.Empty: modifiers[i];
}
/// <summary>
/// Copy this tuple, but modify it to use the new underlying type.
/// </summary>
......@@ -569,7 +559,7 @@ internal static int IsElementNameReserved(string name)
/// <param name="relativeMember">A reference to a well-known member type descriptor. Note however that the type in that descriptor is ignored here.</param>
internal static Symbol GetWellKnownMemberInType(NamedTypeSymbol type, WellKnownMember relativeMember)
{
Debug.Assert(relativeMember >= 0 && relativeMember < WellKnownMember.Count);
Debug.Assert(relativeMember >= WellKnownMember.System_ValueTuple_T1__Item1 && relativeMember <= WellKnownMember.System_ValueTuple_TRest__ctor);
Debug.Assert(type.IsDefinition);
MemberDescriptor relativeDescriptor = WellKnownMembers.GetDescriptor(relativeMember);
......@@ -946,60 +936,61 @@ private static void CollectTargetTupleFields(NamedTypeSymbol underlying, ArrayBu
{
get
{
if (_lazyUnderlyingDefinitionToMemberMap == null)
{
var map = new SmallDictionary<Symbol, Symbol>(ReferenceEqualityComparer.Instance);
var underlyingDefinition = _underlyingType.OriginalDefinition;
var members = GetMembers();
return _lazyUnderlyingDefinitionToMemberMap ??
(_lazyUnderlyingDefinitionToMemberMap = ComputeDefinitionToMemberMap());
}
}
// Go in reverse because we want members with default name, which precede the ones with
// friendly names, to be in the map.
for (int i = members.Length - 1; i >= 0; i--)
{
var member = members[i];
switch (member.Kind)
{
case SymbolKind.Method:
map.Add(((MethodSymbol)member).TupleUnderlyingMethod.OriginalDefinition, member);
break;
private SmallDictionary<Symbol, Symbol> ComputeDefinitionToMemberMap()
{
var map = new SmallDictionary<Symbol, Symbol>(ReferenceEqualityComparer.Instance);
case SymbolKind.Field:
var tupleUnderlyingField = ((FieldSymbol)member).TupleUnderlyingField;
if ((object)tupleUnderlyingField != null)
{
map[tupleUnderlyingField.OriginalDefinition] = member;
}
break;
var underlyingDefinition = _underlyingType.OriginalDefinition;
var members = GetMembers();
case SymbolKind.Property:
map.Add(((PropertySymbol)member).TupleUnderlyingProperty.OriginalDefinition, member);
break;
// Go in reverse because we want members with default name, which precede the ones with
// friendly names, to be in the map.
for (int i = members.Length - 1; i >= 0; i--)
{
var member = members[i];
switch (member.Kind)
{
case SymbolKind.Method:
map.Add(((MethodSymbol)member).TupleUnderlyingMethod.OriginalDefinition, member);
break;
case SymbolKind.Event:
var underlyingEvent = ((EventSymbol)member).TupleUnderlyingEvent;
var underlyingAssociatedField = underlyingEvent.AssociatedField;
// The field is not part of the members list
if ((object)underlyingAssociatedField != null)
{
Debug.Assert((object)underlyingAssociatedField.ContainingSymbol == _underlyingType);
Debug.Assert(_underlyingType.GetMembers(underlyingAssociatedField.Name).IndexOf(underlyingAssociatedField) < 0);
map.Add(underlyingAssociatedField.OriginalDefinition, new TupleFieldSymbol(this, underlyingAssociatedField, -i - 1));
}
case SymbolKind.Field:
var tupleUnderlyingField = ((FieldSymbol)member).TupleUnderlyingField;
if ((object)tupleUnderlyingField != null)
{
map[tupleUnderlyingField.OriginalDefinition] = member;
}
break;
map.Add(underlyingEvent.OriginalDefinition, member);
break;
case SymbolKind.Property:
map.Add(((PropertySymbol)member).TupleUnderlyingProperty.OriginalDefinition, member);
break;
default:
throw ExceptionUtilities.UnexpectedValue(member.Kind);
case SymbolKind.Event:
var underlyingEvent = ((EventSymbol)member).TupleUnderlyingEvent;
var underlyingAssociatedField = underlyingEvent.AssociatedField;
// The field is not part of the members list
if ((object)underlyingAssociatedField != null)
{
Debug.Assert((object)underlyingAssociatedField.ContainingSymbol == _underlyingType);
Debug.Assert(_underlyingType.GetMembers(underlyingAssociatedField.Name).IndexOf(underlyingAssociatedField) < 0);
map.Add(underlyingAssociatedField.OriginalDefinition, new TupleFieldSymbol(this, underlyingAssociatedField, -i - 1));
}
}
_lazyUnderlyingDefinitionToMemberMap = map;
}
map.Add(underlyingEvent.OriginalDefinition, member);
break;
return _lazyUnderlyingDefinitionToMemberMap;
default:
throw ExceptionUtilities.UnexpectedValue(member.Kind);
}
}
return map;
}
public TMember GetTupleMemberSymbolForUnderlyingMember<TMember>(TMember underlyingMemberOpt) where TMember : Symbol
......
......@@ -51,41 +51,6 @@ internal override bool HasSpecialName
}
}
public override abstract TypeSymbol Type
{
get;
}
public override abstract MethodSymbol AddMethod
{
get;
}
public override abstract MethodSymbol RemoveMethod
{
get;
}
internal override abstract FieldSymbol AssociatedField
{
get;
}
internal override abstract bool IsExplicitInterfaceImplementation
{
get;
}
public override abstract ImmutableArray<EventSymbol> ExplicitInterfaceImplementations
{
get;
}
public override abstract Symbol ContainingSymbol
{
get;
}
public override string Name
{
get
......@@ -179,13 +144,6 @@ internal override ObsoleteAttributeData ObsoleteAttributeData
}
}
public override abstract ImmutableArray<CSharpAttributeData> GetAttributes();
internal override abstract bool MustCallMethodsDirectly
{
get;
}
public override bool IsWindowsRuntimeEvent
{
get
......
......@@ -4,7 +4,6 @@
using System.Diagnostics;
using System.Globalization;
using System.Threading;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.Symbols
{
......@@ -41,18 +40,6 @@ public override bool IsImplicitlyDeclared
get { return _underlyingField.IsImplicitlyDeclared; }
}
internal override abstract TypeSymbol GetFieldType(ConsList<FieldSymbol> fieldsBeingBound);
public override abstract ImmutableArray<CustomModifier> CustomModifiers
{
get;
}
public override abstract Symbol ContainingSymbol
{
get;
}
public override Accessibility DeclaredAccessibility
{
get
......@@ -61,8 +48,6 @@ public override Accessibility DeclaredAccessibility
}
}
public override abstract ImmutableArray<CSharpAttributeData> GetAttributes();
public override string Name
{
get
......@@ -132,11 +117,6 @@ internal override ImmutableArray<byte> MarshallingDescriptor
}
}
public override abstract Symbol AssociatedSymbol
{
get;
}
public override bool IsReadOnly
{
get
......
......@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.Threading;
......@@ -50,21 +49,6 @@ public override int Arity
}
}
public override abstract ImmutableArray<TypeParameterSymbol> TypeParameters
{
get;
}
public override abstract ImmutableArray<TypeSymbol> TypeArguments
{
get;
}
public override abstract bool ReturnsVoid
{
get;
}
internal override RefKind RefKind
{
get
......@@ -73,31 +57,11 @@ internal override RefKind RefKind
}
}
public override abstract TypeSymbol ReturnType
{
get;
}
public override abstract ImmutableArray<CustomModifier> ReturnTypeCustomModifiers
{
get;
}
internal override int ParameterCount
{
get { return UnderlyingMethod.ParameterCount; }
}
public override abstract ImmutableArray<ParameterSymbol> Parameters
{
get;
}
public override abstract Symbol AssociatedSymbol
{
get;
}
public override bool IsExtensionMethod
{
get
......@@ -114,11 +78,6 @@ public override bool HidesBaseMethodsByName
}
}
public override abstract Symbol ContainingSymbol
{
get;
}
public override ImmutableArray<Location> Locations
{
get
......@@ -261,11 +220,6 @@ internal override ImmutableArray<string> GetAppliedConditionalSymbols()
return UnderlyingMethod.GetAppliedConditionalSymbols();
}
public override abstract ImmutableArray<CSharpAttributeData> GetAttributes();
// Get return type attributes
public override abstract ImmutableArray<CSharpAttributeData> GetReturnTypeAttributes();
internal override ObsoleteAttributeData ObsoleteAttributeData
{
get
......@@ -319,16 +273,6 @@ internal override Microsoft.Cci.CallingConvention CallingConvention
}
}
internal override abstract bool IsExplicitInterfaceImplementation
{
get;
}
public override abstract ImmutableArray<MethodSymbol> ExplicitInterfaceImplementations
{
get;
}
internal override bool IsAccessCheckedOnOverride
{
get
......@@ -376,7 +320,5 @@ internal override bool GenerateDebugInfo
return UnderlyingMethod.GenerateDebugInfo;
}
}
internal override abstract int CalculateLocalSyntaxOffset(int localPosition, SyntaxTree localTree);
}
}
......@@ -6,7 +6,6 @@
using System.Globalization;
using System.Runtime.InteropServices;
using System.Threading;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.Symbols
{
......@@ -51,36 +50,6 @@ public override int Arity
}
}
public override abstract ImmutableArray<TypeParameterSymbol> TypeParameters
{
get;
}
internal override abstract ImmutableArray<TypeSymbol> TypeArgumentsNoUseSiteDiagnostics
{
get;
}
internal override abstract bool HasTypeArgumentsCustomModifiers
{
get;
}
internal override abstract ImmutableArray<ImmutableArray<CustomModifier>> TypeArgumentsCustomModifiers
{
get;
}
public override abstract NamedTypeSymbol ConstructedFrom
{
get;
}
public override abstract NamedTypeSymbol EnumUnderlyingType
{
get;
}
public override bool MightContainExtensionMethods
{
get
......@@ -126,33 +95,6 @@ public override string GetDocumentationCommentXml(CultureInfo preferredCulture =
return _underlyingType.GetDocumentationCommentXml(preferredCulture, expandIncludes, cancellationToken);
}
public override abstract IEnumerable<string> MemberNames
{
get;
}
public override abstract ImmutableArray<Symbol> GetMembers();
public override abstract ImmutableArray<Symbol> GetMembers(string name);
internal override abstract IEnumerable<FieldSymbol> GetFieldsToEmit();
internal override abstract IEnumerable<MethodSymbol> GetMethodsToEmit();
internal override abstract IEnumerable<PropertySymbol> GetPropertiesToEmit();
internal override abstract IEnumerable<EventSymbol> GetEventsToEmit();
internal override abstract ImmutableArray<Symbol> GetEarlyAttributeDecodingMembers();
internal override abstract ImmutableArray<Symbol> GetEarlyAttributeDecodingMembers(string name);
public override abstract ImmutableArray<NamedTypeSymbol> GetTypeMembers();
public override abstract ImmutableArray<NamedTypeSymbol> GetTypeMembers(string name);
public override abstract ImmutableArray<NamedTypeSymbol> GetTypeMembers(string name, int arity);
public override Accessibility DeclaredAccessibility
{
get
......@@ -177,11 +119,6 @@ internal override bool IsInterface
}
}
public override abstract Symbol ContainingSymbol
{
get;
}
public override ImmutableArray<Location> Locations
{
get
......@@ -238,33 +175,6 @@ internal override bool IsMetadataSealed
}
}
public override abstract ImmutableArray<CSharpAttributeData> GetAttributes();
internal override abstract IEnumerable<CSharpAttributeData> GetCustomAttributesToEmit(ModuleCompilationState compilationState);
internal override abstract NamedTypeSymbol BaseTypeNoUseSiteDiagnostics
{
get;
}
internal override abstract ImmutableArray<NamedTypeSymbol> InterfacesNoUseSiteDiagnostics(ConsList<Symbol> basesBeingResolved);
internal override abstract ImmutableArray<NamedTypeSymbol> GetInterfacesToEmit();
internal override abstract NamedTypeSymbol GetDeclaredBaseType(ConsList<Symbol> basesBeingResolved);
internal override abstract ImmutableArray<NamedTypeSymbol> GetDeclaredInterfaces(ConsList<Symbol> basesBeingResolved);
internal override abstract NamedTypeSymbol ComImportCoClass
{
get;
}
internal override abstract bool IsComImport
{
get;
}
internal override ObsoleteAttributeData ObsoleteAttributeData
{
get { return _underlyingType.ObsoleteAttributeData; }
......
......@@ -34,11 +34,6 @@ public ParameterSymbol UnderlyingParameter
}
}
public abstract override Symbol ContainingSymbol
{
get;
}
#region Forwarded
public override TypeSymbol Type
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
......@@ -49,21 +48,6 @@ internal override RefKind RefKind
}
}
public override abstract TypeSymbol Type
{
get;
}
public override abstract ImmutableArray<CustomModifier> TypeCustomModifiers
{
get;
}
public override abstract ImmutableArray<ParameterSymbol> Parameters
{
get;
}
public override bool IsIndexer
{
get
......@@ -72,16 +56,6 @@ public override bool IsIndexer
}
}
public override abstract MethodSymbol GetMethod
{
get;
}
public override abstract MethodSymbol SetMethod
{
get;
}
internal override Microsoft.Cci.CallingConvention CallingConvention
{
get
......@@ -90,21 +64,6 @@ internal override Microsoft.Cci.CallingConvention CallingConvention
}
}
internal override abstract bool IsExplicitInterfaceImplementation
{
get;
}
public override abstract ImmutableArray<PropertySymbol> ExplicitInterfaceImplementations
{
get;
}
public override abstract Symbol ContainingSymbol
{
get;
}
public override string Name
{
get
......@@ -206,13 +165,6 @@ internal override ObsoleteAttributeData ObsoleteAttributeData
}
}
public override abstract ImmutableArray<CSharpAttributeData> GetAttributes();
internal override abstract bool MustCallMethodsDirectly
{
get;
}
public override string MetadataName
{
get
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Immutable;
using System.Threading;
using Roslyn.Utilities;
using System.Diagnostics;
using System.Globalization;
using System.Threading;
namespace Microsoft.CodeAnalysis.CSharp.Symbols
{
......@@ -90,11 +89,6 @@ public override VarianceKind Variance
}
}
public override abstract Symbol ContainingSymbol
{
get;
}
public override ImmutableArray<Location> Locations
{
get
......@@ -111,8 +105,6 @@ public override ImmutableArray<SyntaxReference> DeclaringSyntaxReferences
}
}
public override abstract ImmutableArray<CSharpAttributeData> GetAttributes();
public override string Name
{
get
......@@ -130,13 +122,5 @@ internal override void EnsureAllConstraintsAreResolved()
{
_underlyingTypeParameter.EnsureAllConstraintsAreResolved();
}
internal override abstract ImmutableArray<TypeSymbol> GetConstraintTypes(ConsList<TypeParameterSymbol> inProgress);
internal override abstract ImmutableArray<NamedTypeSymbol> GetInterfaces(ConsList<TypeParameterSymbol> inProgress);
internal override abstract NamedTypeSymbol GetEffectiveBaseClass(ConsList<TypeParameterSymbol> inProgress);
internal override abstract TypeSymbol GetDeducedBaseType(ConsList<TypeParameterSymbol> inProgress);
}
}
......@@ -4492,33 +4492,190 @@ class C
{
static void Main()
{
(dynamic, dynamic) t = (1, 2);
System.Console.WriteLine(t);
(dynamic, dynamic) d1 = (1, 1); // implicit to dynamic
System.Console.WriteLine(d1);
t = M();
System.Console.WriteLine(t);
(dynamic, dynamic) d2 = M();
System.Console.WriteLine(d2);
(int, int) t2 = (3, 4);
t = t2;
System.Console.WriteLine(t);
(int, int) t3 = (3, 3);
(dynamic, dynamic) d3 = t3;
System.Console.WriteLine(d3);
(int, int) t3 = (5, 6);
t = ((dynamic, dynamic))t3;
System.Console.WriteLine(t);
(int, int) t4 = (4, 4);
(dynamic, dynamic) d4 = ((dynamic, dynamic))t4; // explicit to dynamic
System.Console.WriteLine(d4);
dynamic d5 = 5;
(int, int) t5 = (d5, d5); // implicit from dynamic
System.Console.WriteLine(t5);
(dynamic, dynamic) d6 = (6, 6);
(int, int) t6 = ((int, int))d6; // explicit from dynamic
System.Console.WriteLine(t6);
(dynamic, dynamic) d7;
(int, int) t7 = (7, 7);
d7 = t7;
System.Console.WriteLine(d7);
}
static (dynamic, dynamic) M()
{
return (""hello"", ""world"");
return (2, 2);
}
}
";
string expectedOutput =
@"(1, 2)
(hello, world)
(3, 4)
(5, 6)
@"(1, 1)
(2, 2)
(3, 3)
(4, 4)
(5, 5)
(6, 6)
(7, 7)
";
var comp = CompileAndVerify(source, additionalRefs: new[] { ValueTupleRef, SystemRuntimeFacadeRef, SystemCoreRef, CSharpRef }, expectedOutput: expectedOutput);
comp.VerifyDiagnostics();
}
[Fact]
[WorkItem(12082, "https://github.com/dotnet/roslyn/issues/12082")]
public void TupleWithDynamic2()
{
var source = @"
class C
{
static void Main()
{
(dynamic, dynamic) d = (1, 1);
(int, int) t = d;
}
}
";
var comp = CreateCompilationWithMscorlib(source, references: new[] { ValueTupleRef, SystemRuntimeFacadeRef, SystemCoreRef, CSharpRef });
comp.VerifyDiagnostics(
// (7,24): error CS0266: Cannot implicitly convert type '(dynamic, dynamic)' to '(int, int)'. An explicit conversion exists (are you missing a cast?)
// (int, int) t = d;
Diagnostic(ErrorCode.ERR_NoImplicitConvCast, "d").WithArguments("(dynamic, dynamic)", "(int, int)").WithLocation(7, 24)
);
}
[Fact]
public void TupleWithDynamic3()
{
var source = @"
class C
{
public static void Main()
{
dynamic longTuple = (a: 2, b: 2, c: 2, d: 2, e: 2, f: 2, g: 2, h: 2, i: 2);
System.Console.Write($""Item1: {longTuple.Item1} Rest: {longTuple.Rest}"");
try
{
System.Console.Write(longTuple.a);
System.Console.Write(""unreachable"");
}
catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException) {}
try
{
System.Console.Write(longTuple.i);
System.Console.Write(""unreachable"");
}
catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException) {}
try
{
System.Console.Write(longTuple.Item9);
System.Console.Write(""unreachable"");
}
catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException) {}
}
}
";
var comp = CompileAndVerify(source, expectedOutput: "Item1: 2 Rest: (2, 2)", additionalRefs: new[] { ValueTupleRef, SystemRuntimeFacadeRef, SystemCoreRef, CSharpRef });
comp.VerifyDiagnostics( );
}
[Fact]
public void TupleWithDynamic4()
{
var source = @"
class C
{
public static void Main()
{
dynamic x = (1, 2, 3, 4, 5, 6, 7, 8, 9);
M(x);
}
public static void M((int a, int, int, int, int, int, int, int h, int i) t)
{
System.Console.Write($""a:{t.a}, h:{t.h}, i:{t.i}, Item9:{t.Item9}, Rest:{t.Rest}"");
}
}
";
var comp = CompileAndVerify(source, expectedOutput: "a:1, h:8, i:9, Item9:9, Rest:(8, 9)", additionalRefs: new[] { ValueTupleRef, SystemRuntimeFacadeRef, SystemCoreRef, CSharpRef });
comp.VerifyDiagnostics();
}
[Fact]
public void TupleWithDynamic5()
{
var source = @"
class C
{
public static void Main()
{
dynamic d = (1, 2);
try
{
(string, string) t = d;
System.Console.Write(""unreachable"");
}
catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException) {}
System.Console.Write(""done"");
}
}
";
var comp = CompileAndVerify(source, additionalRefs: new[] { ValueTupleRef, SystemRuntimeFacadeRef, SystemCoreRef }, expectedOutput: expectedOutput);
var comp = CompileAndVerify(source, expectedOutput: "done", additionalRefs: new[] { ValueTupleRef, SystemRuntimeFacadeRef, SystemCoreRef, CSharpRef });
comp.VerifyDiagnostics();
}
[Fact]
public void TupleWithDynamic6()
{
var source = @"
class C
{
public static void Main()
{
(int, int) t1 = (1, 1);
M(t1, ""int"");
(byte, byte) t2 = (2, 2);
M(t2, ""byte"");
(dynamic, dynamic) t3 = (3, 3);
M(t3, ""dynamic"");
(string, string) t4 = (""4"", ""4"");
M(t4, ""string"");
}
public static void M((int, int) t, string type) { System.Console.WriteLine($""int overload with value {t} and type {type}""); }
public static void M((dynamic, dynamic) t, string type) { System.Console.WriteLine($""dynamic overload with value {t} and type {type}""); }
}
";
string expectedOutput =
@"int overload with value (1, 1) and type int
int overload with value (2, 2) and type byte
dynamic overload with value (3, 3) and type dynamic
dynamic overload with value (4, 4) and type string";
var comp = CompileAndVerify(source, expectedOutput: expectedOutput, additionalRefs: new[] { ValueTupleRef, SystemRuntimeFacadeRef, SystemCoreRef, CSharpRef });
comp.VerifyDiagnostics();
}
......@@ -12582,6 +12739,41 @@ void M()
);
}
[Fact]
public void TupleWithDynamicInSeparateCompilations()
{
var lib_cs = @"
public class C
{
public static (dynamic, dynamic) M((dynamic, dynamic) x)
{
return x;
}
}
";
var source = @"
class D
{
static void Main()
{
var x = C.M((1, ""hello""));
x.Item1.DynamicMethod1();
x.Item2.DynamicMethod2();
}
}
";
var libComp = CreateCompilationWithMscorlib(lib_cs, assemblyName: "lib", references: new[] { ValueTupleRef, SystemRuntimeFacadeRef, SystemCoreRef });
libComp.VerifyDiagnostics();
var comp1 = CreateCompilationWithMscorlib(source, references: new[] { libComp.ToMetadataReference(), ValueTupleRef, SystemRuntimeFacadeRef });
comp1.VerifyDiagnostics();
var comp2 = CreateCompilationWithMscorlib(source, references: new[] { libComp.EmitToImageReference(), ValueTupleRef, SystemRuntimeFacadeRef });
comp2.VerifyDiagnostics();
}
[Fact]
[WorkItem(11322, "https://github.com/dotnet/roslyn/issues/11322")]
public void LiteralsAndAmbiguousVT_01()
......@@ -14925,7 +15117,6 @@ public override void M<T>(T x)
// Metadata
var comp4 = CreateCompilationWithMscorlib45(source2, references: new[] { comp2.EmitToImageReference() });
comp4.VerifyDiagnostics();
}
}
......
......@@ -251,7 +251,6 @@
<Compile Include="InternalUtilities\IReadOnlySet.cs" />
<Compile Include="Collections\KeyedStack.cs" />
<Compile Include="Collections\OrderPreservingMultiDictionary.cs" />
<Compile Include="Collections\PooledStringBuilder.cs" />
<Compile Include="Collections\SmallConcurrentSetOfInts.cs" />
<Compile Include="Collections\SmallDictionary.cs" />
<Compile Include="Collections\UnionCollection.cs" />
......@@ -790,8 +789,8 @@
</ProjectReference>
</ItemGroup>
<Import Project="..\AnalyzerDriver\AnalyzerDriver.projitems" Label="Shared" />
<Import Project="..\SharedCollections\SharedCollections.projitems" Label="Shared" />
<Import Project="..\..\Metadata\Microsoft.CodeAnalysis.Metadata.projitems" Label="Shared" />
<Import Project="..\..\..\Dependencies\CodeAnalysis.Metadata\Microsoft.CodeAnalysis.Metadata.projitems" Label="Shared" />
<Import Project="..\..\..\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems" Label="Shared" />
<ImportGroup Label="Targets">
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
</ImportGroup>
......
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>c1930979-c824-496b-a630-70f5369a636f</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import
Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import
Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props"
Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props')" />
<Import
Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props"
Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props')" />
<PropertyGroup />
<Import Project="SharedCollections.projitems" Label="Shared" />
<Import
Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets"
Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets')" />
</Project>
......@@ -14,5 +14,6 @@
<Compile Include="$(MSBuildThisFileDirectory)ObjectPool`1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PooledDictionary.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PooledHashSet.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PooledStringBuilder.cs" />
</ItemGroup>
</Project>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>cd77a8cc-2885-47a7-b99c-fbf13353400b</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props')" />
<PropertyGroup />
<Import Project="Microsoft.CodeAnalysis.PooledObjects.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets')" />
</Project>
\ No newline at end of file
......@@ -156,6 +156,10 @@
<Compile Include="CodeActions\IntroduceVariable\IntroduceVariableTests.cs" />
<Compile Include="CodeActions\InvertIf\InvertIfTests.cs" />
<Compile Include="CodeActions\LambdaSimplifier\LambdaSimplifierTests.cs" />
<Compile Include="CodeActions\MoveType\CSharpMoveTypeTestsBase.cs" />
<Compile Include="CodeActions\MoveType\MoveTypeTests.MoveToNewFile.cs" />
<Compile Include="CodeActions\MoveType\MoveTypeTests.RenameType.cs" />
<Compile Include="CodeActions\MoveType\MoveTypeTests.RenameFile.cs" />
<Compile Include="CodeActions\ReplacePropertyWithMethods\ReplacePropertyWithMethodsTests.cs" />
<Compile Include="Completion\CompletionServiceTests.cs" />
<Compile Include="Diagnostics\AddUsing\AddUsingTests_NuGet.cs" />
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeRefactorings;
using Microsoft.CodeAnalysis.CodeRefactorings.MoveType;
using Microsoft.CodeAnalysis.Editor.UnitTests.MoveType;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.CodeActions.MoveType
{
public abstract class CSharpMoveTypeTestsBase : AbstractMoveTypeTest
{
protected override ParseOptions GetScriptOptions()
{
return Options.Script;
}
protected override Task<TestWorkspace> CreateWorkspaceFromFileAsync(string definition, ParseOptions parseOptions, CompilationOptions compilationOptions)
{
return TestWorkspace.CreateCSharpAsync(definition, parseOptions, compilationOptions);
}
protected override string GetLanguage()
{
return LanguageNames.CSharp;
}
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks;
using Roslyn.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.CodeActions.MoveType
{
public partial class MoveTypeTests : CSharpMoveTypeTestsBase
{
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task TestForSpans1()
{
var code =
@"[|clas|]s Class1 { }
class Class2 { }";
var codeAfterMove = @"class Class2 { }";
var expectedDocumentName = "Class1.cs";
var destinationDocumentText = @"class Class1 { }";
await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task TestForSpans2()
{
var code =
@"[|class Class1|] { }
class Class2 { }";
var codeAfterMove = @"class Class2 { }";
var expectedDocumentName = "Class1.cs";
var destinationDocumentText = @"class Class1 { }";
await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task TestForSpans3()
{
var code =
@"class Class1[||] { }
class Class2 { }";
var codeAfterMove = @"class Class2 { }";
var expectedDocumentName = "Class1.cs";
var destinationDocumentText = @"class Class1 { }";
await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task MoveTypeWithNoContainerNamespace()
{
var code =
@"[||]class Class1 { }
class Class2 { }";
var codeAfterMove = @"class Class2 { }";
var expectedDocumentName = "Class1.cs";
var destinationDocumentText = @"class Class1 { }";
await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task MoveTypeWithWithUsingsAndNoContainerNamespace()
{
var code =
@"// Banner Text
using System;
[||]class Class1 { }
class Class2 { }";
var codeAfterMove =
@"// Banner Text
class Class2 { }";
var expectedDocumentName = "Class1.cs";
var destinationDocumentText =
@"class Class1 { }";
await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task MoveTypeWithWithMembers()
{
var code =
@"// Banner Text
using System;
[||]class Class1
{
void Print(int x)
{
Console.WriteLine(x);
}
}
class Class2 { }";
var codeAfterMove =
@"// Banner Text
class Class2 { }";
var expectedDocumentName = "Class1.cs";
var destinationDocumentText =
@"
using System;
class Class1
{
void Print(int x)
{
Console.WriteLine(x);
}
}";
await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task MoveTypeWithWithMembers2()
{
var code =
@"// Banner Text
using System;
[||]class Class1
{
void Print(int x)
{
Console.WriteLine(x);
}
}
class Class2
{
void Print(int x)
{
Console.WriteLine(x);
}
}";
var codeAfterMove =
@"// Banner Text
using System;
class Class2
{
void Print(int x)
{
Console.WriteLine(x);
}
}";
var expectedDocumentName = "Class1.cs";
var destinationDocumentText =
@"
using System;
class Class1
{
void Print(int x)
{
Console.WriteLine(x);
}
}";
await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task MoveAnInterface()
{
var code =
@"[||]interface IMoveType { }
class Class2 { }";
var codeAfterMove = @"class Class2 { }";
var expectedDocumentName = "IMoveType.cs";
var destinationDocumentText = @"interface IMoveType { }";
await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task MoveAStruct()
{
var code =
@"[||]struct MyStruct { }
class Class2 { }";
var codeAfterMove = @"class Class2 { }";
var expectedDocumentName = "MyStruct.cs";
var destinationDocumentText = @"struct MyStruct { }";
await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task MoveAnEnum()
{
var code =
@"[||]enum MyEnum { }
class Class2 { }";
var codeAfterMove = @"class Class2 { }";
var expectedDocumentName = "MyEnum.cs";
var destinationDocumentText = @"enum MyEnum { }";
await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task MoveTypeWithWithContainerNamespace()
{
var code =
@"namespace N1
{
[||]class Class1 { }
class Class2 { }
}";
var codeAfterMove =
@"namespace N1
{
class Class2 { }
}";
var expectedDocumentName = "Class1.cs";
var destinationDocumentText =
@"namespace N1
{
class Class1 { }
}";
await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task MoveNestedTypeToNewFile_Simple()
{
var code =
@"namespace N1
{
class Class1
{
[||]class Class2 { }
}
}";
var codeAfterMove =
@"namespace N1
{
partial class Class1
{
}
}";
var expectedDocumentName = "Class2.cs";
var destinationDocumentText =
@"namespace N1
{
partial class Class1
{
class Class2
{
}
}
}";
await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task MoveNestedTypeToNewFile_ParentHasOtherMembers()
{
var code =
@"namespace N1
{
class Class1
{
private int _field1;
[||]class Class2 { }
public void Method1() { }
}
}";
var codeAfterMove =
@"namespace N1
{
partial class Class1
{
private int _field1;
public void Method1() { }
}
}";
var expectedDocumentName = "Class2.cs";
var destinationDocumentText =
@"namespace N1
{
partial class Class1
{
class Class2
{
}
}
}";
await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task MoveNestedTypeToNewFile_HasOtherTopLevelMembers()
{
var code =
@"namespace N1
{
class Class1
{
private int _field1;
[||]class Class2 { }
public void Method1() { }
}
internal class Class3
{
private void Method1() { }
}
}";
var codeAfterMove =
@"namespace N1
{
partial class Class1
{
private int _field1;
public void Method1() { }
}
internal class Class3
{
private void Method1() { }
}
}";
var expectedDocumentName = "Class2.cs";
var destinationDocumentText =
@"namespace N1
{
partial class Class1
{
class Class2
{
}
}
}";
await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task MoveNestedTypeToNewFile_HasMembers()
{
var code =
@"namespace N1
{
class Class1
{
private int _field1;
[||]class Class2
{
private string _field1;
public void InnerMethod() { }
}
public void Method1() { }
}
}";
var codeAfterMove =
@"namespace N1
{
partial class Class1
{
private int _field1;
public void Method1() { }
}
}";
var expectedDocumentName = "Class2.cs";
var destinationDocumentText =
@"namespace N1
{
partial class Class1
{
class Class2
{
private string _field1;
public void InnerMethod() { }
}
}
}";
await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText);
}
}
}
\ No newline at end of file
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks;
using Roslyn.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.CodeActions.MoveType
{
public partial class MoveTypeTests : CSharpMoveTypeTestsBase
{
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task SingleClassInFile_RenameFile()
{
var code =
@"[||]class Class1 { }";
var expectedDocumentName = "Class1.cs";
await TestRenameFileToMatchTypeAsync(code, expectedDocumentName);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task MoreThanOneTypeInFile_RenameFile()
{
var code =
@"[||]class Class1
{
class Inner { }
}";
var expectedDocumentName = "Class1.cs";
await TestRenameFileToMatchTypeAsync(code, expectedDocumentName);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task TypeNameMatchesFileName_RenameFile()
{
// testworkspace creates files like test1.cs, test2.cs and so on..
// so type name matches filename here and rename file action should not be offered.
var code =
@"[||]class test1 { }";
await TestRenameFileToMatchTypeAsync(code, expectedCodeAction: false);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task MoreThanOneTopLevelTypeInFile_RenameFile()
{
var code =
@"[||]class Class1 { }
class Class2 { }";
await TestRenameFileToMatchTypeAsync(code, expectedCodeAction: false);
}
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks;
using Roslyn.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.CodeActions.MoveType
{
public partial class MoveTypeTests : CSharpMoveTypeTestsBase
{
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task SingleClassInFile_RenameType()
{
var code =
@"[||]class Class1 { }";
var codeWithTypeRenamedToMatchFileName =
@"class [|test1|] { }";
await TestRenameTypeToMatchFileAsync(code, codeWithTypeRenamedToMatchFileName);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task MoreThanOneTypeInFile_RenameType()
{
var code =
@"[||]class Class1
{
class Inner { }
}";
var codeWithTypeRenamedToMatchFileName =
@"class [|test1|]
{
class Inner { }
}";
await TestRenameTypeToMatchFileAsync(code, codeWithTypeRenamedToMatchFileName);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task TypeNameMatchesFileName_RenameType()
{
// testworkspace creates files like test1.cs, test2.cs and so on..
// so type name matches filename here and rename file action should not be offered.
var code =
@"[||]class test1 { }";
await TestRenameTypeToMatchFileAsync(code, expectedCodeAction: false);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)]
public async Task MoreThanOneTopLevelTypeInFile_RenameType()
{
var code =
@"[||]class Class1 { }
class Class2 { }";
await TestRenameTypeToMatchFileAsync(code, expectedCodeAction: false);
}
}
}
......@@ -14,7 +14,7 @@
namespace Microsoft.CodeAnalysis.Editor.Implementation.FindReferences
{
internal abstract class AbstractFindReferencesService : IFindReferencesService
internal abstract partial class AbstractFindReferencesService : IFindReferencesService
{
private readonly IEnumerable<IReferencedSymbolsPresenter> _referenceSymbolPresenters;
private readonly IEnumerable<INavigableItemsPresenter> _navigableItemPresenters;
......@@ -30,9 +30,10 @@ internal abstract class AbstractFindReferencesService : IFindReferencesService
_externalReferencesProviders = externalReferencesProviders;
}
private async Task<Tuple<IEnumerable<ReferencedSymbol>, Solution>> FindReferencedSymbolsAsync(Document document, int position, IWaitContext waitContext)
private async Task<Tuple<ISymbol, Solution>> GetRelevantSymbolAndSolutionAtPositionAsync(
Document document, int position, CancellationToken cancellationToken)
{
var cancellationToken = waitContext.CancellationToken;
cancellationToken.ThrowIfCancellationRequested();
var symbol = await SymbolFinder.FindSymbolAtPositionAsync(document, position, cancellationToken: cancellationToken).ConfigureAwait(false);
if (symbol != null)
......@@ -45,14 +46,7 @@ internal abstract class AbstractFindReferencesService : IFindReferencesService
var mapping = await mappingService.MapSymbolAsync(document, symbol, cancellationToken).ConfigureAwait(false);
if (mapping != null)
{
var displayName = mapping.Symbol.IsConstructor() ? mapping.Symbol.ContainingType.Name : mapping.Symbol.Name;
waitContext.Message = string.Format(EditorFeaturesResources.Finding_references_of_0, displayName);
var result = await SymbolFinder.FindReferencesAsync(mapping.Symbol, mapping.Solution, cancellationToken).ConfigureAwait(false);
var searchSolution = mapping.Solution;
return Tuple.Create(result, searchSolution);
return Tuple.Create(mapping.Symbol, mapping.Solution);
}
}
......@@ -75,6 +69,30 @@ private async Task AddExternalReferencesAsync(Document document, int position, A
}
}
private async Task<Tuple<IEnumerable<ReferencedSymbol>, Solution>> FindReferencedSymbolsAsync(
Document document, int position, IWaitContext waitContext)
{
var cancellationToken = waitContext.CancellationToken;
var symbolAndSolution = await GetRelevantSymbolAndSolutionAtPositionAsync(document, position, cancellationToken).ConfigureAwait(false);
if (symbolAndSolution == null)
{
return null;
}
var symbol = symbolAndSolution.Item1;
var solution = symbolAndSolution.Item2;
var displayName = symbol.IsConstructor() ? symbol.ContainingType.Name : symbol.Name;
waitContext.Message = string.Format(
EditorFeaturesResources.Finding_references_of_0, displayName);
var result = await SymbolFinder.FindReferencesAsync(symbol, solution, cancellationToken).ConfigureAwait(false);
return Tuple.Create(result, solution);
}
public bool TryFindReferences(Document document, int position, IWaitContext waitContext)
{
var cancellationToken = waitContext.CancellationToken;
......
......@@ -8,6 +8,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes.Suppression;
using Microsoft.CodeAnalysis.Editor.Implementation.Preview;
using Microsoft.CodeAnalysis.Editor.UnitTests.Extensions;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.Options;
......@@ -152,6 +153,147 @@ public abstract class AbstractCodeActionOrUserDiagnosticTest
}
}
protected async Task TestAddDocument(
string initialMarkup, string expectedMarkup,
IList<string> expectedContainers,
string expectedDocumentName,
int index = 0,
bool compareTokens = true, bool isLine = true)
{
await TestAddDocument(initialMarkup, expectedMarkup, index, expectedContainers, expectedDocumentName, parseOptions: null, compilationOptions: null, compareTokens: compareTokens, isLine: isLine);
await TestAddDocument(initialMarkup, expectedMarkup, index, expectedContainers, expectedDocumentName, GetScriptOptions(), compilationOptions: null, compareTokens: compareTokens, isLine: isLine);
}
protected async Task<Tuple<Solution, Solution>> TestAddDocumentAsync(
TestWorkspace workspace,
string expectedMarkup,
int index,
string expectedDocumentName,
IList<string> expectedContainers,
bool compareTokens = true)
{
var codeActions = await GetCodeActionsAsync(workspace, fixAllActionEquivalenceKey: null);
return await TestAddDocument(workspace, expectedMarkup, index, expectedContainers, expectedDocumentName,
codeActions, compareTokens);
}
private async Task TestAddDocument(
string initialMarkup, string expectedMarkup,
int index,
IList<string> expectedContainers,
string expectedDocumentName,
ParseOptions parseOptions, CompilationOptions compilationOptions,
bool compareTokens, bool isLine)
{
using (var workspace = isLine
? await CreateWorkspaceFromFileAsync(initialMarkup, parseOptions, compilationOptions)
: await TestWorkspace.CreateAsync(initialMarkup))
{
var codeActions = await GetCodeActionsAsync(workspace, fixAllActionEquivalenceKey: null);
await TestAddDocument(workspace, expectedMarkup, index, expectedContainers, expectedDocumentName,
codeActions, compareTokens);
}
}
private async Task<Tuple<Solution, Solution>> TestAddDocument(
TestWorkspace workspace,
string expectedMarkup,
int index,
IList<string> expectedFolders,
string expectedDocumentName,
IList<CodeAction> actions,
bool compareTokens)
{
var operations = await VerifyInputsAndGetOperationsAsync(index, actions);
return await TestAddDocument(
workspace,
expectedMarkup,
operations,
hasProjectChange: false,
modifiedProjectId: null,
expectedFolders: expectedFolders,
expectedDocumentName: expectedDocumentName,
compareTokens: compareTokens);
}
protected async Task<Tuple<Solution, Solution>> TestAddDocument(
TestWorkspace workspace,
string expected,
IEnumerable<CodeActionOperation> operations,
bool hasProjectChange,
ProjectId modifiedProjectId,
IList<string> expectedFolders,
string expectedDocumentName,
bool compareTokens)
{
var appliedChanges = ApplyOperationsAndGetSolution(workspace, operations);
var oldSolution = appliedChanges.Item1;
var newSolution = appliedChanges.Item2;
Document addedDocument = null;
if (!hasProjectChange)
{
addedDocument = SolutionUtilities.GetSingleAddedDocument(oldSolution, newSolution);
}
else
{
Assert.NotNull(modifiedProjectId);
addedDocument = newSolution.GetProject(modifiedProjectId).Documents.SingleOrDefault(doc => doc.Name == expectedDocumentName);
}
Assert.NotNull(addedDocument);
AssertEx.Equal(expectedFolders, addedDocument.Folders);
Assert.Equal(expectedDocumentName, addedDocument.Name);
if (compareTokens)
{
TokenUtilities.AssertTokensEqual(
expected, (await addedDocument.GetTextAsync()).ToString(), GetLanguage());
}
else
{
Assert.Equal(expected, (await addedDocument.GetTextAsync()).ToString());
}
var editHandler = workspace.ExportProvider.GetExportedValue<ICodeActionEditHandlerService>();
if (!hasProjectChange)
{
// If there is just one document change then we expect the preview to be a WpfTextView
var content = (await editHandler.GetPreviews(workspace, operations, CancellationToken.None).GetPreviewsAsync())[0];
using (var diffView = content as DifferenceViewerPreview)
{
Assert.NotNull(diffView.Viewer);
}
}
else
{
// If there are more changes than just the document we need to browse all the changes and get the document change
var contents = editHandler.GetPreviews(workspace, operations, CancellationToken.None);
bool hasPreview = false;
var previews = await contents.GetPreviewsAsync();
if (previews != null)
{
foreach (var preview in previews)
{
if (preview != null)
{
var diffView = preview as DifferenceViewerPreview;
if (diffView?.Viewer != null)
{
hasPreview = true;
diffView.Dispose();
break;
}
}
}
}
Assert.True(hasPreview);
}
return Tuple.Create(oldSolution, newSolution);
}
internal async Task TestAsync(
string initialMarkup, string expectedMarkup,
int index = 0, bool compareTokens = true,
......
......@@ -23,7 +23,6 @@
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
using Xunit;
using Microsoft.CodeAnalysis.Editor.Implementation.Preview;
namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics
{
......@@ -281,133 +280,6 @@ protected async Task TestEquivalenceKeyAsync(string initialMarkup, string equiva
}
}
protected async Task TestAddDocument(
string initialMarkup, string expectedMarkup,
IList<string> expectedContainers,
string expectedDocumentName,
int index = 0,
bool compareTokens = true, bool isLine = true)
{
await TestAddDocument(initialMarkup, expectedMarkup, index, expectedContainers, expectedDocumentName, null, null, compareTokens, isLine);
await TestAddDocument(initialMarkup, expectedMarkup, index, expectedContainers, expectedDocumentName, GetScriptOptions(), null, compareTokens, isLine);
}
private async Task TestAddDocument(
string initialMarkup, string expectedMarkup,
int index,
IList<string> expectedContainers,
string expectedDocumentName,
ParseOptions parseOptions, CompilationOptions compilationOptions,
bool compareTokens, bool isLine)
{
using (var workspace = isLine
? await CreateWorkspaceFromFileAsync(initialMarkup, parseOptions, compilationOptions)
: await TestWorkspace.CreateAsync(initialMarkup))
{
var codeActions = await GetCodeActionsAsync(workspace, fixAllActionEquivalenceKey: null);
await TestAddDocument(workspace, expectedMarkup, index, expectedContainers, expectedDocumentName,
codeActions, compareTokens);
}
}
private async Task TestAddDocument(
TestWorkspace workspace,
string expectedMarkup,
int index,
IList<string> expectedFolders,
string expectedDocumentName,
IList<CodeAction> actions,
bool compareTokens)
{
var operations = await VerifyInputsAndGetOperationsAsync(index, actions);
await TestAddDocument(
workspace,
expectedMarkup,
operations,
hasProjectChange: false,
modifiedProjectId: null,
expectedFolders: expectedFolders,
expectedDocumentName: expectedDocumentName,
compareTokens: compareTokens);
}
private async Task<Tuple<Solution, Solution>> TestAddDocument(
TestWorkspace workspace,
string expected,
IEnumerable<CodeActionOperation> operations,
bool hasProjectChange,
ProjectId modifiedProjectId,
IList<string> expectedFolders,
string expectedDocumentName,
bool compareTokens)
{
var appliedChanges = ApplyOperationsAndGetSolution(workspace, operations);
var oldSolution = appliedChanges.Item1;
var newSolution = appliedChanges.Item2;
Document addedDocument = null;
if (!hasProjectChange)
{
addedDocument = SolutionUtilities.GetSingleAddedDocument(oldSolution, newSolution);
}
else
{
Assert.NotNull(modifiedProjectId);
addedDocument = newSolution.GetProject(modifiedProjectId).Documents.SingleOrDefault(doc => doc.Name == expectedDocumentName);
}
Assert.NotNull(addedDocument);
AssertEx.Equal(expectedFolders, addedDocument.Folders);
Assert.Equal(expectedDocumentName, addedDocument.Name);
if (compareTokens)
{
TokenUtilities.AssertTokensEqual(
expected, (await addedDocument.GetTextAsync()).ToString(), GetLanguage());
}
else
{
Assert.Equal(expected, (await addedDocument.GetTextAsync()).ToString());
}
var editHandler = workspace.ExportProvider.GetExportedValue<ICodeActionEditHandlerService>();
if (!hasProjectChange)
{
// If there is just one document change then we expect the preview to be a WpfTextView
var content = (await editHandler.GetPreviews(workspace, operations, CancellationToken.None).GetPreviewsAsync())[0];
var diffView = content as DifferenceViewerPreview;
Assert.NotNull(diffView.Viewer);
diffView.Dispose();
}
else
{
// If there are more changes than just the document we need to browse all the changes and get the document change
var contents = editHandler.GetPreviews(workspace, operations, CancellationToken.None);
bool hasPreview = false;
var previews = await contents.GetPreviewsAsync();
if (previews != null)
{
foreach (var preview in previews)
{
if (preview != null)
{
var diffView = preview as DifferenceViewerPreview;
if (diffView?.Viewer != null)
{
hasPreview = true;
diffView.Dispose();
break;
}
}
}
}
Assert.True(hasPreview);
}
return Tuple.Create(oldSolution, newSolution);
}
internal async Task TestWithMockedGenerateTypeDialog(
string initial,
string languageName,
......
......@@ -218,6 +218,7 @@
<Compile Include="Extensions\SourceTextContainerExtensionsTests.cs" />
<Compile Include="Extensions\WorkspaceExtensions.cs" />
<Compile Include="GoToAdjacentMember\AbstractGoToAdjacentMemberTests.cs" />
<Compile Include="MoveType\AbstractMoveTypeTest.cs" />
<Compile Include="Outlining\AbstractSyntaxNodeOutlinerTests.cs" />
<Compile Include="Outlining\AbstractSyntaxOutlinerTests.cs" />
<Compile Include="Outlining\AbstractSyntaxTriviaOutlinerTests.cs" />
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeRefactorings;
using Microsoft.CodeAnalysis.CodeRefactorings.MoveType;
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.UnitTests;
using Roslyn.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.Editor.UnitTests.MoveType
{
public abstract class AbstractMoveTypeTest : AbstractCodeActionTest
{
private string RenameFileCodeActionTitle = FeaturesResources.Rename_file_to_0;
private string RenameTypeCodeActionTitle = FeaturesResources.Rename_type_to_0;
protected override CodeRefactoringProvider CreateCodeRefactoringProvider(Workspace workspace)
{
return new MoveTypeCodeRefactoringProvider();
}
protected async Task TestRenameTypeToMatchFileAsync(
string originalCode,
string expectedCode = null,
bool expectedCodeAction = true,
bool compareTokens = true)
{
using (var workspace = await CreateWorkspaceFromFileAsync(originalCode, parseOptions: null, compilationOptions: null))
{
if (expectedCodeAction)
{
Assert.True(expectedCode != null, $"{nameof(expectedCode)} should be present if {nameof(expectedCodeAction)} is true.");
var documentId = workspace.Documents[0].Id;
var documentName = workspace.Documents[0].Name;
string expectedText;
TextSpan span;
MarkupTestFile.GetSpan(expectedCode, out expectedText, out span);
var codeActionTitle = string.Format(RenameTypeCodeActionTitle, expectedText.Substring(span.Start, span.Length));
var oldSolutionAndNewSolution = await TestOperationAsync(
workspace, expectedText, codeActionTitle, compareTokens);
// the original source document does not exist in the new solution.
var newSolution = oldSolutionAndNewSolution.Item2;
var document = newSolution.GetDocument(documentId);
Assert.NotNull(document);
Assert.Equal(documentName, document.Name);
}
else
{
var actions = await GetCodeActionsAsync(workspace, fixAllActionEquivalenceKey: null);
if (actions != null)
{
var renameFileAction = actions.Any(action => action.Title.StartsWith(RenameTypeCodeActionTitle));
Assert.False(renameFileAction, "Rename Type to match file name code action was not expected, but shows up.");
}
}
}
}
protected async Task TestRenameFileToMatchTypeAsync(
string originalCode,
string expectedDocumentName = null,
bool expectedCodeAction = true,
bool compareTokens = true)
{
using (var workspace = await CreateWorkspaceFromFileAsync(originalCode, parseOptions: null, compilationOptions: null))
{
if (expectedCodeAction)
{
Assert.True(expectedDocumentName != null, $"{nameof(expectedDocumentName)} should be present if {nameof(expectedCodeAction)} is true.");
var oldDocumentId = workspace.Documents[0].Id;
string expectedText;
IList<TextSpan> spans;
MarkupTestFile.GetSpans(originalCode, out expectedText, out spans);
var codeActionTitle = string.Format(RenameFileCodeActionTitle, expectedDocumentName);
// a new document with the same text as old document is added.
var oldSolutionAndNewSolution = await TestOperationAsync(
workspace, expectedText, codeActionTitle, compareTokens);
// the original source document does not exist in the new solution.
var newSolution = oldSolutionAndNewSolution.Item2;
Assert.Null(newSolution.GetDocument(oldDocumentId));
}
else
{
var actions = await GetCodeActionsAsync(workspace, fixAllActionEquivalenceKey: null);
if (actions != null)
{
var renameFileAction = actions.Any(action => action.Title.StartsWith(RenameFileCodeActionTitle));
Assert.False(renameFileAction, "Rename File to match type code action was not expected, but shows up.");
}
}
}
}
private async Task<Tuple<Solution, Solution>> TestOperationAsync(
Workspaces.TestWorkspace workspace,
string expectedCode,
string operation,
bool compareTokens)
{
var actions = await GetCodeActionsAsync(workspace, fixAllActionEquivalenceKey: null);
var action = actions.Single(a => a.Title.StartsWith(operation));
var operations = await action.GetOperationsAsync(CancellationToken.None);
return await TestOperationsAsync(workspace,
expectedText: expectedCode,
operations: operations,
conflictSpans: null,
renameSpans: null,
warningSpans: null,
compareTokens: compareTokens,
expectedChangedDocumentId: null);
}
protected async Task TestMoveTypeToNewFileAsync(
string originalCode,
string expectedSourceTextAfterRefactoring,
string expectedDocumentName,
string destinationDocumentText,
IList<string> destinationDocumentContainers = null,
bool expectedCodeAction = true,
int index = 0,
bool compareTokens = true)
{
if (expectedCodeAction)
{
using (var workspace = await CreateWorkspaceFromFileAsync(originalCode, parseOptions: null, compilationOptions: null))
{
// replace with default values on null.
if (destinationDocumentContainers == null)
{
destinationDocumentContainers = Array.Empty<string>();
}
var sourceDocumentId = workspace.Documents[0].Id;
// Verify the newly added document and its text
var oldSolutionAndNewSolution = await TestAddDocumentAsync(workspace,
destinationDocumentText, index, expectedDocumentName, destinationDocumentContainers, compareTokens: compareTokens);
// Verify source document's text after moving type.
var oldSolution = oldSolutionAndNewSolution.Item1;
var newSolution = oldSolutionAndNewSolution.Item2;
var changedDocumentIds = SolutionUtilities.GetChangedDocuments(oldSolution, newSolution);
Assert.True(changedDocumentIds.Contains(sourceDocumentId), "source document was not changed.");
var modifiedSourceDocument = newSolution.GetDocument(sourceDocumentId);
if (compareTokens)
{
TokenUtilities.AssertTokensEqual(
expectedSourceTextAfterRefactoring, (await modifiedSourceDocument.GetTextAsync()).ToString(), GetLanguage());
}
else
{
Assert.Equal(expectedSourceTextAfterRefactoring, (await modifiedSourceDocument.GetTextAsync()).ToString());
}
}
}
else
{
await TestMissingAsync(originalCode, parseOptions: null);
}
}
}
}
......@@ -68,6 +68,7 @@ public static class Features
public const string CodeActionsMakeMethodSynchronous = "CodeActions.MakeMethodSynchronous";
public const string CodeActionsMoveDeclarationNearReference = "CodeActions.MoveDeclarationNearReference";
public const string CodeActionsMoveToTopOfFile = "CodeActions.MoveToTopOfFile";
public const string CodeActionsMoveType = "CodeActions.MoveType";
public const string CodeActionsPopulateSwitch = "CodeActions.PopulateSwitch";
public const string CodeActionsQualifyMemberAccess = "CodeActions.QualifyMemberAccess";
public const string CodeActionsReplaceMethodWithProperty = "CodeActions.ReplaceMethodWithProperty";
......
......@@ -136,6 +136,10 @@
<Compile Include="CodeActions\InlineTemporary\InlineTemporaryTests.vb" />
<Compile Include="CodeActions\IntroduceVariable\IntroduceVariableTests.vb" />
<Compile Include="CodeActions\InvertIf\InvertIfTests.vb" />
<Compile Include="CodeActions\MoveType\BasicMoveTypeTestsBase.vb" />
<Compile Include="CodeActions\MoveType\MoveTypeTests.MoveToNewFile.vb" />
<Compile Include="CodeActions\MoveType\MoveTypeTests.RenameType.vb" />
<Compile Include="CodeActions\MoveType\MoveTypeTests.RenameFile.vb" />
<Compile Include="CodeActions\Preview\PreviewTests.vb" />
<Compile Include="CodeActions\ReplacePropertyWithMethods\ReplacePropertyWithMethodsTests.vb" />
<Compile Include="Completion\CompletionServiceTests.vb" />
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Xml.Linq
Imports Microsoft.CodeAnalysis.CodeRefactorings
Imports Microsoft.CodeAnalysis.CodeRefactorings.MoveType
Imports Microsoft.CodeAnalysis.Editor.UnitTests.MoveType
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeRefactorings.MoveType
Public Class BasicMoveTypeTestsBase
Inherits AbstractMoveTypeTest
Protected Overrides Function CreateWorkspaceFromFileAsync(
definition As String,
ParseOptions As ParseOptions,
CompilationOptions As CompilationOptions
) As Task(Of TestWorkspace)
Return TestWorkspace.CreateVisualBasicAsync(
definition,
ParseOptions,
If(CompilationOptions, New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary)))
End Function
Protected Overrides Function GetLanguage() As String
Return LanguageNames.VisualBasic
End Function
Protected Overrides Function GetScriptOptions() As ParseOptions
Return TestOptions.Script
End Function
Protected Overloads Function TestRenameTypeToMatchFileAsync(
originalCode As XElement,
Optional expectedCode As XElement = Nothing,
Optional expectedCodeAction As Boolean = True,
Optional compareTokens As Boolean = True
) As Task
Dim expectedText As String = Nothing
If Not expectedCode Is Nothing Then
expectedText = expectedCode.ConvertTestSourceTag()
End If
Return MyBase.TestRenameTypeToMatchFileAsync(
originalCode.ConvertTestSourceTag(), expectedText, expectedCodeAction, compareTokens)
End Function
Protected Overloads Function TestRenameFileToMatchTypeAsync(
originalCode As XElement,
Optional expectedDocumentName As String = Nothing,
Optional expectedCodeAction As Boolean = True,
Optional compareTokens As Boolean = True
) As Task
Return MyBase.TestRenameFileToMatchTypeAsync(
originalCode.ConvertTestSourceTag(), expectedDocumentName, expectedCodeAction, compareTokens)
End Function
Protected Overloads Function TestMoveTypeToNewFileAsync(
originalCode As XElement,
expectedSourceTextAfterRefactoring As XElement,
expectedDocumentName As String,
destinationDocumentText As XElement,
Optional destinationDocumentContainers As IList(Of String) = Nothing,
Optional expectedCodeAction As Boolean = True,
Optional index As Integer = 0,
Optional compareTokens As Boolean = True
) As Task
Dim originalCodeText = originalCode.ConvertTestSourceTag()
Dim expectedSourceText = expectedSourceTextAfterRefactoring.ConvertTestSourceTag()
Dim expectedDestinationText = destinationDocumentText.ConvertTestSourceTag()
Return MyBase.TestMoveTypeToNewFileAsync(
originalCodeText,
expectedSourceText,
expectedDocumentName,
expectedDestinationText,
destinationDocumentContainers,
expectedCodeAction,
index,
compareTokens)
End Function
End Class
End Namespace
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeRefactorings.MoveType
Partial Public Class MoveTypeTests
Inherits BasicMoveTypeTestsBase
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)>
Public Async Function MultipleTypesInFileWithNoContainerNamespace() As Task
Dim code =
<File>
[||]Class Class1
End Class
Class Class2
End Class
</File>
Dim codeAfterMove =
<File>
Class Class2
End Class
</File>
Dim expectedDocumentName = "Class1.vb"
Dim destinationDocumentText =
<File>
Class Class1
End Class
</File>
Await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText)
End Function
End Class
End Namespace
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeRefactorings.MoveType
Partial Public Class MoveTypeTests
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)>
Public Async Function SingleClassInFileWithNoContainerNamespace_RenameFile() As Task
Dim code =
<File>
[||]Class Class1
End Class
</File>
Dim expectedDocumentName = "Class1.vb"
Await TestRenameFileToMatchTypeAsync(code, expectedDocumentName)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)>
Public Async Function TypeNameMatchesFileName_RenameFile() As Task
' testworkspace creates files Like test1.cs, test2.cs And so on..
' so type name matches filename here And rename file action should Not be offered.
Dim code =
<File>
[||]Class test1
End Class
</File>
Await TestRenameFileToMatchTypeAsync(code, expectedCodeAction:=False)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)>
Public Async Function MoreThanOneTypeInFile_RenameFile() As Task
Dim code =
<File>
[||]Class Class1
End Class
Class Class2
End Class
</File>
Await TestRenameFileToMatchTypeAsync(code, expectedCodeAction:=False)
End Function
End Class
End Namespace
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeRefactorings.MoveType
Partial Public Class MoveTypeTests
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)>
Public Async Function SingleClassInFileWithNoContainerNamespace_RenameType() As Task
Dim code =
<File>
[||]Class Class1
End Class
</File>
Dim codeAfterRenamingType =
<File>
Class [|test1|]
End Class
</File>
Await TestRenameTypeToMatchFileAsync(code, codeAfterRenamingType)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)>
Public Async Function TypeNameMatchesFileName_RenameType() As Task
' testworkspace creates files Like test1.cs, test2.cs And so on..
' so type name matches filename here And rename file action should Not be offered.
Dim code =
<File>
[||]Class test1
End Class
</File>
Await TestRenameTypeToMatchFileAsync(code, expectedCodeAction:=False)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveType)>
Public Async Function MoreThanOneTypeInFile_RenameType() As Task
Dim code =
<File>
[||]Class Class1
End Class
Class Class2
End Class
</File>
Await TestRenameTypeToMatchFileAsync(code, expectedCodeAction:=False)
End Function
End Class
End Namespace
......@@ -21,7 +21,7 @@
<Compile Include="..\..\..\..\..\Compilers\Core\Portable\CaseInsensitiveComparison.cs">
<Link>Compiler\CaseInsensitiveComparison.cs</Link>
</Compile>
<Compile Include="..\..\..\..\..\Compilers\Core\Portable\Collections\PooledStringBuilder.cs">
<Compile Include="..\..\..\..\..\Dependencies\PooledObjects\PooledStringBuilder.cs">
<Link>Compiler\Collections\PooledStringBuilder.cs</Link>
</Compile>
<Compile Include="..\..\..\..\..\Compilers\Core\Portable\InternalUtilities\FailFast.cs">
......@@ -36,7 +36,7 @@
<Compile Include="..\..\..\..\..\Compilers\Core\Portable\InternalUtilities\ExceptionUtilities.cs">
<Link>Compiler\InternalUtilities\ExceptionUtilities.cs</Link>
</Compile>
<Compile Include="..\..\..\..\..\Compilers\Core\SharedCollections\ObjectPool`1.cs">
<Compile Include="..\..\..\..\..\Dependencies\PooledObjects\ObjectPool`1.cs">
<Link>Compiler\InternalUtilities\ObjectPool`1.cs</Link>
</Compile>
<Compile Include="..\..\..\..\..\Compilers\Core\Portable\SymbolDisplay\ObjectDisplayExtensions.cs">
......
......@@ -26,7 +26,7 @@
<Compile Include="..\..\..\..\..\Compilers\Core\Portable\CaseInsensitiveComparison.cs">
<Link>Compiler\CaseInsensitiveComparison.cs</Link>
</Compile>
<Compile Include="..\..\..\..\..\Compilers\Core\Portable\Collections\PooledStringBuilder.cs">
<Compile Include="..\..\..\..\..\Dependencies\PooledObjects\PooledStringBuilder.cs">
<Link>Compiler\Collections\PooledStringBuilder.cs</Link>
</Compile>
<Compile Include="..\..\..\..\..\Compilers\Core\Portable\InternalUtilities\FailFast.cs">
......@@ -44,7 +44,7 @@
<Compile Include="..\..\..\..\..\Compilers\Core\Portable\InternalUtilities\ReflectionUtilities.cs">
<Link>Compiler\InternalUtilities\ReflectionUtilities.cs</Link>
</Compile>
<Compile Include="..\..\..\..\..\Compilers\Core\SharedCollections\ObjectPool`1.cs">
<Compile Include="..\..\..\..\..\Dependencies\PooledObjects\ObjectPool`1.cs">
<Link>Compiler\InternalUtilities\ObjectPool`1.cs</Link>
</Compile>
<Compile Include="..\..\..\..\..\Compilers\Core\Portable\SymbolDisplay\ObjectDisplayExtensions.cs">
......
......@@ -42,7 +42,7 @@
<Reference Include="System" />
</ItemGroup>
<ItemGroup Label="Linked Files">
<Compile Include="..\..\..\..\Compilers\Core\Portable\Collections\PooledStringBuilder.cs">
<Compile Include="..\..\..\..\Dependencies\PooledObjects\PooledStringBuilder.cs">
<Link>Compiler\Collections\PooledStringBuilder.cs</Link>
</Compile>
<Compile Include="..\..\..\..\Compilers\Core\Portable\InternalUtilities\FailFast.cs">
......@@ -60,7 +60,7 @@
<Compile Include="..\..\..\..\Compilers\Core\Portable\InternalUtilities\ReflectionUtilities.cs">
<Link>Compiler\InternalUtilities\ReflectionUtilities.cs</Link>
</Compile>
<Compile Include="..\..\..\..\Compilers\Core\SharedCollections\ObjectPool`1.cs">
<Compile Include="..\..\..\..\Dependencies\PooledObjects\ObjectPool`1.cs">
<Link>Compiler\InternalUtilities\ObjectPool`1.cs</Link>
</Compile>
<Compile Include="..\..\..\..\Compilers\Core\Portable\SymbolDisplay\ObjectDisplayExtensions.cs">
......
......@@ -104,6 +104,7 @@
<Compile Include="CodeRefactorings\MoveDeclarationNearReference\MoveDeclarationNearReferenceCodeRefactoringProvider.cs" />
<Compile Include="CodeRefactorings\MoveDeclarationNearReference\MoveDeclarationNearReferenceCodeRefactoringProvider.Rewriter.cs" />
<Compile Include="CodeRefactorings\MoveDeclarationNearReference\MoveDeclarationNearReferenceCodeRefactoringProvider.State.cs" />
<Compile Include="CodeRefactorings\MoveType\CSharpMoveTypeService.cs" />
<Compile Include="Completion\CompletionProviders\AttributeNamedParameterCompletionProvider.cs" />
<Compile Include="Completion\CompletionProviders\CompletionUtilities.cs" />
<Compile Include="Completion\CompletionProviders\CrefCompletionProvider.cs" />
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Composition;
using Microsoft.CodeAnalysis.CodeRefactorings.MoveType;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Host.Mef;
namespace Microsoft.CodeAnalysis.CSharp.CodeRefactorings.MoveType
{
[ExportLanguageService(typeof(IMoveTypeService), LanguageNames.CSharp), Shared]
internal class CSharpMoveTypeService :
AbstractMoveTypeService<CSharpMoveTypeService, BaseTypeDeclarationSyntax, NamespaceDeclarationSyntax, MemberDeclarationSyntax, CompilationUnitSyntax>
{
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
namespace Microsoft.CodeAnalysis.CodeRefactorings.MoveType
{
internal abstract partial class AbstractMoveTypeService<TService, TTypeDeclarationSyntax, TNamespaceDeclarationSyntax, TMemberDeclarationSyntax, TCompilationUnitSyntax>
{
/// <summary>
/// An abstract class for different edits performed by the Move Type Code Action.
/// </summary>
private abstract class Editor
{
public Editor(
TService service,
State state,
CancellationToken cancellationToken)
{
State = state;
Service = service;
CancellationToken = cancellationToken;
}
protected State State { get; }
protected TService Service { get; }
protected CancellationToken CancellationToken { get; }
protected SemanticDocument SemanticDocument => State.SemanticDocument;
/// <summary>
/// operations performed by CodeAction.
/// </summary>
internal abstract Task<IEnumerable<CodeActionOperation>> GetOperationsAsync();
}
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CodeRefactorings.MoveType
{
internal abstract partial class AbstractMoveTypeService<TService, TTypeDeclarationSyntax, TNamespaceDeclarationSyntax, TMemberDeclarationSyntax, TCompilationUnitSyntax>
{
private class MoveTypeCodeAction : CodeAction
{
private readonly State _state;
private readonly TService _service;
private readonly OperationKind _operationKind;
private readonly string _title;
public MoveTypeCodeAction(
TService service,
State state,
OperationKind operationKind)
{
_state = state;
_service = service;
_operationKind = operationKind;
_title = CreateDisplayText();
}
private string CreateDisplayText()
{
switch (_operationKind)
{
case OperationKind.MoveType:
return string.Format(FeaturesResources.Move_type_to_0, _state.TargetFileNameCandidate);
case OperationKind.RenameType:
return string.Format(FeaturesResources.Rename_type_to_0, _state.DocumentName);
case OperationKind.RenameFile:
return string.Format(FeaturesResources.Rename_file_to_0, _state.TargetFileNameCandidate);
}
throw ExceptionUtilities.Unreachable;
}
public override string Title => _title;
protected override Task<IEnumerable<CodeActionOperation>> ComputeOperationsAsync(CancellationToken cancellationToken)
{
var editor = GetEditor(cancellationToken);
return editor.GetOperationsAsync();
}
private Editor GetEditor(CancellationToken cancellationToken)
{
switch (_operationKind)
{
case OperationKind.MoveType:
return new MoveTypeEditor(_service, _state, cancellationToken);
case OperationKind.RenameType:
return new RenameTypeEditor(_service, _state, cancellationToken);
case OperationKind.RenameFile:
return new RenameFileEditor(_service, _state, cancellationToken);
}
throw ExceptionUtilities.Unreachable;
}
}
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.RemoveUnnecessaryImports;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CodeRefactorings.MoveType
{
internal abstract partial class AbstractMoveTypeService<TService, TTypeDeclarationSyntax, TNamespaceDeclarationSyntax, TMemberDeclarationSyntax, TCompilationUnitSyntax>
{
private class MoveTypeEditor : Editor
{
public MoveTypeEditor(
TService service,
State state,
CancellationToken cancellationToken) : base(service, state, cancellationToken)
{
}
/// <summary>
/// Given a document and a type contained in it, moves the type
/// out to its own document. The new document's name typically
/// is the type name, or is atleast based on the type name.
/// </summary>
/// <remarks>
/// The algorithm for this, is as follows:
/// 1. Fork the original document that contains the type to be moved.
/// 2. Keep the type, required namespace containers and using statements.
/// remove everything else from the forked document.
/// 3. Add this forked document to the solution.
/// 4. Finally, update the original document and remove the type from it.
/// </remarks>
internal override async Task<IEnumerable<CodeActionOperation>> GetOperationsAsync()
{
var solution = SemanticDocument.Document.Project.Solution;
// Fork, update and add as new document.
var projectToBeUpdated = SemanticDocument.Document.Project;
var newDocumentId = DocumentId.CreateNewId(projectToBeUpdated.Id, State.TargetFileNameCandidate);
var solutionWithNewDocument = await AddNewDocumentWithSingleTypeDeclarationAndImportsAsync(newDocumentId).ConfigureAwait(false);
// Get the original source document again, from the latest forked solution.
var sourceDocument = solutionWithNewDocument.GetDocument(SemanticDocument.Document.Id);
// update source document to add partial modifiers to type chain
// and/or remove type declaration from original source document.
var solutionWithBothDocumentsUpdated = await RemoveTypeFromSourceDocumentAsync(
sourceDocument).ConfigureAwait(false);
return SpecializedCollections.SingletonEnumerable(new ApplyChangesOperation(solutionWithBothDocumentsUpdated));
}
/// <summary>
/// Forks the source document, keeps required type, namespace containers
/// and adds it the solution.
/// </summary>
/// <param name="newDocumentId">id for the new document to be added</param>
/// <returns>the new solution which contains a new document with the type being moved</returns>
private async Task<Solution> AddNewDocumentWithSingleTypeDeclarationAndImportsAsync(
DocumentId newDocumentId)
{
Debug.Assert(SemanticDocument.Document.Name != State.TargetFileNameCandidate,
$"New document name is same as old document name:{State.TargetFileNameCandidate}");
var root = SemanticDocument.Root;
var projectToBeUpdated = SemanticDocument.Document.Project;
var documentEditor = await DocumentEditor.CreateAsync(SemanticDocument.Document, CancellationToken).ConfigureAwait(false);
AddPartialModifiersToTypeChain(documentEditor);
// remove things that are not being moved, from the forked document.
var membersToRemove = GetMembersToRemove(root);
foreach (var member in membersToRemove)
{
documentEditor.RemoveNode(member, SyntaxRemoveOptions.KeepNoTrivia);
}
var modifiedRoot = documentEditor.GetChangedRoot();
// add an empty document to solution, so that we'll have options from the right context.
var solutionWithNewDocument = projectToBeUpdated.Solution.AddDocument(newDocumentId, State.TargetFileNameCandidate, text: string.Empty);
// update the text for the new document
solutionWithNewDocument = solutionWithNewDocument.WithDocumentSyntaxRoot(newDocumentId, modifiedRoot, PreservationMode.PreserveIdentity);
// get the updated document, perform clean up like remove unused usings.
var newDocument = solutionWithNewDocument.GetDocument(newDocumentId);
newDocument = await CleanUpDocumentAsync(newDocument).ConfigureAwait(false);
return newDocument.Project.Solution;
}
/// <summary>
/// update the original document and remove the type that was moved.
/// perform other fix ups as necessary.
/// </summary>
/// <param name="sourceDocument">original document</param>
/// <returns>an updated solution with the original document fixed up as appropriate.</returns>
private async Task<Solution> RemoveTypeFromSourceDocumentAsync(Document sourceDocument)
{
var documentEditor = await DocumentEditor.CreateAsync(sourceDocument, CancellationToken).ConfigureAwait(false);
AddPartialModifiersToTypeChain(documentEditor);
documentEditor.RemoveNode(State.TypeNode, SyntaxRemoveOptions.KeepNoTrivia);
var updatedDocument = documentEditor.GetChangedDocument();
updatedDocument = await CleanUpDocumentAsync(updatedDocument).ConfigureAwait(false);
return updatedDocument.Project.Solution;
}
/// <summary>
/// Traverses the syntax tree of the forked document and
/// collects a list of nodes that are not being moved.
/// This list of nodes are then removed from the forked copy.
/// </summary>
/// <param name="root">root, of the syntax tree of forked document</param>
/// <returns>list of syntax nodes, to be removed from the forked copy.</returns>
private IEnumerable<SyntaxNode> GetMembersToRemove(SyntaxNode root)
{
var spine = new HashSet<SyntaxNode>();
// collect the parent chain of declarations to keep.
spine.AddRange(State.TypeNode.GetAncestors());
// get potential namespace, types and members to remove.
var removableCandidates = root
.DescendantNodes(n => DescendIntoChildren(n, spine.Contains(n)))
.Where(n => FilterToTopLevelMembers(n, State.TypeNode));
// diff candidates with items we want to keep.
return removableCandidates.Except(spine);
}
private static bool DescendIntoChildren(SyntaxNode node, bool shouldDescendIntoType)
{
// 1. get top level types and namespaces to remove.
// 2. descend into types and get members to remove, only if type is part of spine, which means
// we'll be keeping the type declaration but not other members, in the new file.
return node is TCompilationUnitSyntax
|| node is TNamespaceDeclarationSyntax
|| (node is TTypeDeclarationSyntax && shouldDescendIntoType);
}
private static bool FilterToTopLevelMembers(SyntaxNode node, SyntaxNode typeNode)
{
// It is a type declaration that is not the node we've moving
// or its a container namespace, or a member declaration that is not a type,
// thereby ignoring other stuff like statements and identifiers.
return node is TTypeDeclarationSyntax
? !node.Equals(typeNode)
: (node is TNamespaceDeclarationSyntax || node is TMemberDeclarationSyntax);
}
/// <summary>
/// if a nested type is being moved, this ensures its containing type is partial.
/// </summary>
/// <param name="documentEditor">document editor for the new document being created</param>
private void AddPartialModifiersToTypeChain(DocumentEditor documentEditor)
{
var semanticFacts = State.SemanticDocument.Document.GetLanguageService<ISemanticFactsService>();
var typeChain = State.TypeNode.Ancestors().OfType<TTypeDeclarationSyntax>();
foreach (var node in typeChain)
{
var symbol = (ITypeSymbol)State.SemanticDocument.SemanticModel.GetDeclaredSymbol(node, CancellationToken);
if (!semanticFacts.IsPartial(symbol, CancellationToken))
{
documentEditor.SetModifiers(node, DeclarationModifiers.Partial);
}
}
}
/// <summary>
/// Perform clean ups on a given document.
/// </summary>
private Task<Document> CleanUpDocumentAsync(Document document)
{
return document
.GetLanguageService<IRemoveUnnecessaryImportsService>()
.RemoveUnnecessaryImportsAsync(document, CancellationToken);
}
}
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
namespace Microsoft.CodeAnalysis.CodeRefactorings.MoveType
{
internal abstract partial class AbstractMoveTypeService<TService, TTypeDeclarationSyntax, TNamespaceDeclarationSyntax, TMemberDeclarationSyntax, TCompilationUnitSyntax>
{
private class RenameFileEditor : Editor
{
public RenameFileEditor(TService service, State state, CancellationToken cancellationToken)
: base(service, state, cancellationToken)
{
}
internal override Task<IEnumerable<CodeActionOperation>> GetOperationsAsync()
{
return Task.FromResult(RenameFileToMatchTypeName());
}
/// <summary>
/// Renames the file to match the type contained in it.
/// </summary>
private IEnumerable<CodeActionOperation> RenameFileToMatchTypeName()
{
var solution = SemanticDocument.Document.Project.Solution;
var text = SemanticDocument.Text;
var oldDocumentId = SemanticDocument.Document.Id;
var newDocumentId = DocumentId.CreateNewId(SemanticDocument.Document.Project.Id, State.TargetFileNameCandidate);
// currently, document rename is accomplished by a remove followed by an add.
// the workspace takes care of resolving conflicts if the document name is not unique in the project
// by adding numeric suffixes to the new document being added.
var newSolution = solution.RemoveDocument(oldDocumentId);
newSolution = newSolution.AddDocument(newDocumentId, State.TargetFileNameCandidate, text);
return new CodeActionOperation[]
{
new ApplyChangesOperation(newSolution),
new OpenDocumentOperation(newDocumentId)
};
}
}
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.Rename;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CodeRefactorings.MoveType
{
internal abstract partial class AbstractMoveTypeService<TService, TTypeDeclarationSyntax, TNamespaceDeclarationSyntax, TMemberDeclarationSyntax, TCompilationUnitSyntax>
{
private class RenameTypeEditor : Editor
{
public RenameTypeEditor(TService service, State state, CancellationToken cancellationToken)
: base(service, state, cancellationToken)
{
}
internal override Task<IEnumerable<CodeActionOperation>> GetOperationsAsync()
{
return RenameTypeToMatchFileAsync();
}
/// <summary>
/// Renames a type to match its containing file name.
/// </summary>
private async Task<IEnumerable<CodeActionOperation>> RenameTypeToMatchFileAsync()
{
// TODO: detect conflicts ahead of time and open an inline rename session if any exists.
// this will bring up dashboard with conflicts and will allow the user to resolve them.
// if no such conflicts exist, proceed with RenameSymbolAsync.
var solution = SemanticDocument.Document.Project.Solution;
var symbol = State.SemanticDocument.SemanticModel.GetDeclaredSymbol(State.TypeNode, CancellationToken);
var newSolution = await Renamer.RenameSymbolAsync(solution, symbol, State.DocumentName, SemanticDocument.Document.Options, CancellationToken).ConfigureAwait(false);
return SpecializedCollections.SingletonEnumerable(new ApplyChangesOperation(newSolution));
}
}
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.IO;
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.CodeRefactorings.MoveType
{
internal abstract partial class AbstractMoveTypeService<TService, TTypeDeclarationSyntax, TNamespaceDeclarationSyntax, TMemberDeclarationSyntax, TCompilationUnitSyntax>
{
private class State
{
private readonly TService _service;
public SemanticDocument SemanticDocument { get; }
public TTypeDeclarationSyntax TypeNode { get; set; }
public string TypeName { get; set; }
public string DocumentName { get; set; }
public string TargetFileNameCandidate { get; set; }
public bool IsDocumentNameAValidIdentifier { get; set; }
private State(TService service, SemanticDocument document)
{
this._service = service;
this.SemanticDocument = document;
}
internal static State Generate(TService service, SemanticDocument document, TextSpan textSpan, CancellationToken cancellationToken)
{
var state = new State(service, document);
if (!state.TryInitialize(textSpan, cancellationToken))
{
return null;
}
return state;
}
private bool TryInitialize(
TextSpan textSpan,
CancellationToken cancellationToken)
{
if (cancellationToken.IsCancellationRequested)
{
return false;
}
var tree = this.SemanticDocument.SyntaxTree;
var root = this.SemanticDocument.Root;
var syntaxFacts = this.SemanticDocument.Project.LanguageServices.GetService<ISyntaxFactsService>();
var typeDeclaration = _service.GetNodeToAnalyze(root, textSpan) as TTypeDeclarationSyntax;
if (typeDeclaration == null)
{
return false;
}
var typeSymbol = this.SemanticDocument.SemanticModel.GetDeclaredSymbol(typeDeclaration, cancellationToken) as INamedTypeSymbol;
// compiler declared types, anonymous types, types defined in metadata should be filtered out.
if (typeSymbol == null ||
typeSymbol.Locations.Any(loc => loc.IsInMetadata) ||
typeSymbol.IsAnonymousType ||
typeSymbol.IsImplicitlyDeclared)
{
return false;
}
TypeNode = typeDeclaration;
TypeName = typeSymbol.Name;
DocumentName = Path.GetFileNameWithoutExtension(this.SemanticDocument.Document.Name);
IsDocumentNameAValidIdentifier = syntaxFacts.IsValidIdentifier(DocumentName);
// TODO: Make this check better, it won't detect Outer.Inner.cs cases.
if (string.Equals(DocumentName, TypeName, StringComparison.CurrentCulture))
{
// if type name matches document name in a case sensitive manner, we have nothing more to do.
return false;
}
TargetFileNameCandidate = Path.Combine(typeSymbol.Name + Path.GetExtension(this.SemanticDocument.Document.Name));
return true;
}
}
}
}
\ No newline at end of file
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.CodeRefactorings.MoveType
{
internal abstract partial class AbstractMoveTypeService<TService, TTypeDeclarationSyntax, TNamespaceDeclarationSyntax, TMemberDeclarationSyntax, TCompilationUnitSyntax> :
IMoveTypeService
where TService : AbstractMoveTypeService<TService, TTypeDeclarationSyntax, TNamespaceDeclarationSyntax, TMemberDeclarationSyntax, TCompilationUnitSyntax>
where TTypeDeclarationSyntax : SyntaxNode
where TNamespaceDeclarationSyntax : SyntaxNode
where TMemberDeclarationSyntax : SyntaxNode
where TCompilationUnitSyntax : SyntaxNode
{
private enum OperationKind
{
MoveType,
RenameType,
RenameFile
}
protected bool ShouldAnalyze(SyntaxNode root, TextSpan span)
{
return GetNodeToAnalyze(root, span) is TTypeDeclarationSyntax;
}
protected virtual SyntaxNode GetNodeToAnalyze(SyntaxNode root, TextSpan span)
{
return root.FindNode(span);
}
private bool IsNestedType(TTypeDeclarationSyntax typeNode) =>
typeNode.Parent is TTypeDeclarationSyntax;
/// <summary>
/// checks if there is a single top level type declaration in a document
/// </summary>
private bool MultipleTopLevelTypeDeclarationInSourceDocument(SyntaxNode root) =>
root.DescendantNodes(n => (n is TCompilationUnitSyntax || n is TNamespaceDeclarationSyntax))
.OfType<TTypeDeclarationSyntax>()
.Count() > 1;
public async Task<ImmutableArray<CodeAction>> GetRefactoringAsync(Document document, TextSpan textSpan, CancellationToken cancellationToken)
{
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
if (!ShouldAnalyze(root, textSpan))
{
return default(ImmutableArray<CodeAction>);
}
var semanticDocument = await SemanticDocument.CreateAsync(document, cancellationToken).ConfigureAwait(false);
var state = State.Generate((TService)this, semanticDocument, textSpan, cancellationToken);
if (state == null)
{
return default(ImmutableArray<CodeAction>);
}
var actions = CreateActions(state, cancellationToken);
Debug.Assert(actions.Count() != 0, "No code actions found for MoveType Refactoring");
return actions;
}
private ImmutableArray<CodeAction> CreateActions(State state, CancellationToken cancellationToken)
{
var actions = new List<CodeAction>();
var manyTypes = MultipleTopLevelTypeDeclarationInSourceDocument(state.SemanticDocument.Root);
if (manyTypes || IsNestedType(state.TypeNode))
{
// If there are multiple type declarations in current document. offer, move to new file.
// Or if this is a nested type, offer to move to new file.
actions.Add(GetCodeAction(state, operationKind: OperationKind.MoveType));
}
else
{
// one type declaration in current document. No moving around required, just sync
// document name and type name by offering rename in both directions between type and document.
actions.Add(GetCodeAction(state, operationKind: OperationKind.RenameFile));
// only if the document name can be legal identifier in the language,
// offer to rename type with document name
if (state.IsDocumentNameAValidIdentifier)
{
actions.Add(GetCodeAction(state, operationKind: OperationKind.RenameType));
}
}
return actions.ToImmutableArray();
}
private CodeAction GetCodeAction(
State state,
OperationKind operationKind)
{
return new MoveTypeCodeAction((TService)this, state, operationKind);
}
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.CodeRefactorings.MoveType
{
internal interface IMoveTypeService : ILanguageService
{
Task<ImmutableArray<CodeAction>> GetRefactoringAsync(Document document, TextSpan textSpan, CancellationToken cancellationToken);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Composition;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.GeneratedCodeRecognition;
using Microsoft.CodeAnalysis.Shared.Extensions;
namespace Microsoft.CodeAnalysis.CodeRefactorings.MoveType
{
[ExportCodeRefactoringProvider(LanguageNames.CSharp, LanguageNames.VisualBasic,
Name = PredefinedCodeRefactoringProviderNames.MoveTypeToFile), Shared]
internal class MoveTypeCodeRefactoringProvider : CodeRefactoringProvider
{
public override async Task ComputeRefactoringsAsync(CodeRefactoringContext context)
{
var document = context.Document;
var textSpan = context.Span;
var cancellationToken = context.CancellationToken;
var workspace = document.Project.Solution.Workspace;
if (workspace.Kind == WorkspaceKind.MiscellaneousFiles)
{
return;
}
var generatedCodeRecognitionService = workspace.Services.GetService<IGeneratedCodeRecognitionService>();
if (generatedCodeRecognitionService.IsGeneratedCode(document))
{
return;
}
var service = document.GetLanguageService<IMoveTypeService>();
var actions = await service.GetRefactoringAsync(document, textSpan, cancellationToken).ConfigureAwait(false);
if (!actions.IsDefault)
{
context.RegisterRefactorings(actions);
}
}
}
}
......@@ -18,5 +18,6 @@ internal static class PredefinedCodeRefactoringProviderNames
public const string MoveDeclarationNearReference = "Move Declaration Near Reference Code Action Provider";
public const string SimplifyLambda = "Simplify Lambda Code Action Provider";
public const string ConvertToInterpolatedString = "Convert To Interpolated String Code Action Provider";
public const string MoveTypeToFile = "Move Type To File Code Action Provider";
}
}
......@@ -157,6 +157,15 @@
<Compile Include="CodeRefactorings\ICodeRefactoringHelpersService.cs" />
<Compile Include="CodeRefactorings\ICodeRefactoringService.cs" />
<Compile Include="CodeRefactorings\IntroduceVariable\IntroduceVariableCodeRefactoringProvider.cs" />
<Compile Include="CodeRefactorings\MoveType\AbstractMoveTypeService.MoveTypeEditor.cs" />
<Compile Include="CodeRefactorings\MoveType\AbstractMoveTypeService.RenameTypeEditor.cs" />
<Compile Include="CodeRefactorings\MoveType\AbstractMoveTypeService.RenameFileEditor.cs" />
<Compile Include="CodeRefactorings\MoveType\MoveTypeCodeRefactoringProvider.cs" />
<Compile Include="CodeRefactorings\MoveType\AbstractMoveTypeService.Editor.cs" />
<Compile Include="CodeRefactorings\MoveType\AbstractMoveTypeService.MoveTypeCodeAction.cs" />
<Compile Include="CodeRefactorings\MoveType\AbstractMoveTypeService.State.cs" />
<Compile Include="CodeRefactorings\MoveType\AbstractMoveTypeService.cs" />
<Compile Include="CodeRefactorings\MoveType\IMoveTypeService.cs" />
<Compile Include="CodeRefactorings\PredefinedCodeRefactoringProviderNames.cs" />
<Compile Include="CodeRefactorings\ServicesLayerCodeActionHelpersService.cs" />
<Compile Include="CodeRefactorings\WorkspaceServices\IAddMetadataReferenceCodeActionOperationFactoryWorkspaceService.cs" />
......
......@@ -1822,6 +1822,15 @@ internal class FeaturesResources {
}
}
/// <summary>
/// Looks up a localized string similar to Move type to {0}.
/// </summary>
internal static string Move_type_to_0 {
get {
return ResourceManager.GetString("Move_type_to_0", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Moving &apos;{0}&apos; will prevent the debug session from continuing..
/// </summary>
......@@ -2105,6 +2114,24 @@ internal class FeaturesResources {
}
}
/// <summary>
/// Looks up a localized string similar to Rename file to {0}.
/// </summary>
internal static string Rename_file_to_0 {
get {
return ResourceManager.GetString("Rename_file_to_0", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Rename type to {0}.
/// </summary>
internal static string Rename_type_to_0 {
get {
return ResourceManager.GetString("Rename_type_to_0", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Renaming &apos;{0}&apos; will prevent the debug session from continuing..
/// </summary>
......
......@@ -1035,4 +1035,13 @@ This version used in: {2}</value>
<data name="Convert_to_interpolated_string" xml:space="preserve">
<value>Convert to interpolated string</value>
</data>
<data name="Move_type_to_0" xml:space="preserve">
<value>Move type to {0}</value>
</data>
<data name="Rename_file_to_0" xml:space="preserve">
<value>Rename file to {0}</value>
</data>
<data name="Rename_type_to_0" xml:space="preserve">
<value>Rename type to {0}</value>
</data>
</root>
\ No newline at end of file
......@@ -132,6 +132,7 @@
<Compile Include="CodeRefactorings\InlineTemporary\InlineTemporaryCodeRefactoringProvider.ReferenceRewriter.vb" />
<Compile Include="CodeRefactorings\InlineTemporary\InlineTemporaryCodeRefactoringProvider.vb" />
<Compile Include="CodeRefactorings\InvertIf\InvertIfCodeRefactoringProvider.vb" />
<Compile Include="CodeRefactorings\MoveType\VisualBasicMoveTypeService.vb" />
<Compile Include="CodeRefactorings\RemoveStatementCodeAction.vb" />
<Compile Include="Completion\CompletionProviders\CompletionListTagCompletionProvider.vb" />
<Compile Include="Completion\CompletionProviders\CompletionUtilities.vb" />
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Composition
Imports Microsoft.CodeAnalysis.CodeRefactorings.MoveType
Imports Microsoft.CodeAnalysis.Host.Mef
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.CodeRefactorings.MoveType
<ExportLanguageService(GetType(IMoveTypeService), LanguageNames.VisualBasic), [Shared]>
Friend Class VisualBasicMoveTypeService
Inherits AbstractMoveTypeService(Of VisualBasicMoveTypeService, TypeBlockSyntax, NamespaceBlockSyntax, MethodBaseSyntax, CompilationUnitSyntax)
''' <summary>
''' Gets the TypeBlock node to analyze
''' </summary>
Protected Overrides Function GetNodeToAnalyze(root As SyntaxNode, span As TextSpan) As SyntaxNode
Dim node = MyBase.GetNodeToAnalyze(root, span)
If node.IsKind(SyntaxKind.ModuleStatement,
SyntaxKind.ClassStatement,
SyntaxKind.StructureStatement,
SyntaxKind.InterfaceStatement,
SyntaxKind.EnumStatement) Then
Return node.Parent
End If
Return Nothing
End Function
End Class
End Namespace
......@@ -54,9 +54,6 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup Label="Linked Files">
<Compile Include="..\..\Compilers\Core\Portable\Collections\PooledStringBuilder.cs">
<Link>Collections\PooledStringBuilder.cs</Link>
</Compile>
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\ExceptionUtilities.cs">
<Link>InternalUtilities\ExceptionUtilities.cs</Link>
</Compile>
......@@ -106,8 +103,8 @@
<Name>Metadata</Name>
</ProjectReference>
</ItemGroup>
<Import Project="..\..\Compilers\Core\SharedCollections\SharedCollections.projitems" Label="Shared" />
<Import Project="..\..\Compilers\Metadata\Microsoft.CodeAnalysis.Metadata.projitems" Label="Shared" />
<Import Project="..\..\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems" Label="Shared" />
<Import Project="..\..\Dependencies\CodeAnalysis.Metadata\Microsoft.CodeAnalysis.Metadata.projitems" Label="Shared" />
<ImportGroup Label="Targets">
<Import Project="..\..\..\build\Targets\VSL.Imports.targets" />
</ImportGroup>
......
......@@ -45,7 +45,7 @@
<Compile Include="..\..\..\Compilers\Core\Portable\InternalUtilities\ConcurrentLruCache.cs">
<Link>Shared\ConcurrentLruCache.cs</Link>
</Compile>
<Compile Include="..\..\..\Compilers\Core\Portable\Interop\IVsSQM.cs" />
<Compile Include="..\..\..\Compilers\Core\Portable\Interop\IVsSQM.cs" />
<Compile Include="..\..\..\Compilers\Shared\ShadowCopyAnalyzerAssemblyLoader.cs">
<Link>InternalUtilities\ShadowCopyAnalyzerAssemblyLoader.cs</Link>
</Compile>
......@@ -730,7 +730,7 @@
<ItemGroup>
<Folder Include="Implementation\Options\Style\" />
</ItemGroup>
<Import Project="..\..\..\Compilers\Metadata\Microsoft.CodeAnalysis.Metadata.projitems" Label="Shared" />
<Import Project="..\..\..\Dependencies\CodeAnalysis.Metadata\Microsoft.CodeAnalysis.Metadata.projitems" Label="Shared" />
<ImportGroup Label="Targets">
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
</ImportGroup>
......
......@@ -262,5 +262,11 @@ public bool IsNameOfContext(SemanticModel semanticModel, int position, Cancellat
{
return semanticModel.SyntaxTree.IsNameOfContext(position, semanticModel, cancellationToken);
}
public bool IsPartial(ITypeSymbol typeSymbol, CancellationToken cancellationToken)
{
var syntaxRefs = typeSymbol.DeclaringSyntaxReferences;
return syntaxRefs.Any(n => ((BaseTypeDeclarationSyntax)n.GetSyntax(cancellationToken)).Modifiers.Any(SyntaxKind.PartialKeyword));
}
}
}
......@@ -89,5 +89,7 @@ internal interface ISemanticFactsService : ILanguageService
ForEachSymbols GetForEachSymbols(SemanticModel semanticModel, SyntaxNode forEachStatement);
bool IsAssignableTo(ITypeSymbol fromSymbol, ITypeSymbol toSymbol, Compilation compilation);
bool IsPartial(ITypeSymbol typeSymbol, CancellationToken cancellationToken);
}
}
\ No newline at end of file
......@@ -45,9 +45,6 @@
<Compile Include="..\..\..\Compilers\Core\Portable\Collections\OrderPreservingMultiDictionary.cs">
<Link>Utilities\CompilerUtilities\OrderPreservingMultiDictionary.cs</Link>
</Compile>
<Compile Include="..\..\..\Compilers\Core\Portable\Collections\PooledStringBuilder.cs">
<Link>Collections\PooledStringBuilder.cs</Link>
</Compile>
<Compile Include="..\..\..\Compilers\Core\Portable\CorLightup.cs">
<Link>InternalUtilities\CorLightup.cs</Link>
</Compile>
......@@ -1019,7 +1016,7 @@
<PublicAPI Include="PublicAPI.Shipped.txt" />
<PublicAPI Include="PublicAPI.Unshipped.txt" />
</ItemGroup>
<Import Project="..\..\..\Compilers\Core\SharedCollections\SharedCollections.projitems" Label="Shared" />
<Import Project="..\..\..\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems" Label="Shared" />
<ImportGroup Label="Targets">
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
</ImportGroup>
......
......@@ -247,5 +247,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Public Function IsNamespaceDeclarationNameContext(semanticModel As SemanticModel, position As Integer, cancellationToken As CancellationToken) As Boolean Implements ISemanticFactsService.IsNamespaceDeclarationNameContext
Return semanticModel.SyntaxTree.IsNamespaceDeclarationNameContext(position, cancellationToken)
End Function
Public Function IsPartial(typeSymbol As ITypeSymbol, cancellationToken As CancellationToken) As Boolean Implements ISemanticFactsService.IsPartial
Dim syntaxRefs = typeSymbol.DeclaringSyntaxReferences
Return syntaxRefs.Any(
Function(n As SyntaxReference)
Return DirectCast(n.GetSyntax(cancellationToken), TypeStatementSyntax).Modifiers.Any(SyntaxKind.PartialKeyword)
End Function)
End Function
End Class
End Namespace
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册