diff --git a/Directory.Build.props b/Directory.Build.props
index 513fc417b61..cde1d1595f2 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -36,25 +36,24 @@
- netstandard2.0
- net461
+ net462
+ net462
4.3.0
-
+
1.4.0
4.3.2
1.5.0
4.4.0
4.4.0
- 4.4.0
- 15.7.179
- 2.8.2
+ 15.3.409
+ 2.0.0
2.0.0
2.0.0
@@ -73,7 +72,7 @@
3.0.472
8.2.1
- 4.5.2
+ 4.2.3
10.0.10586
@@ -152,7 +151,7 @@
2.1.0
2.1.0
-
+
$(VersionPrefix)
$(VersionPrefix)
diff --git a/Orleans.sln b/Orleans.sln
index 22e7655ff5f..0268fb7e19d 100644
--- a/Orleans.sln
+++ b/Orleans.sln
@@ -112,8 +112,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestServiceFabric", "test\E
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "TestFSharp", "test\Grains\TestFSharp\TestFSharp.fsproj", "{8A652779-85EF-48E2-A639-1EED3CE2C39C}"
EndProject
-Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "TestFSharpInterfaces", "test\Misc\TestFSharpInterfaces\TestFSharpInterfaces.fsproj", "{A4F61392-36A3-457C-80D0-9CDC48F5922F}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrleansManager", "src\OrleansManager\OrleansManager.csproj", "{1153256E-10C2-4729-ACDC-5DF18A7B92B5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.Streaming.GCP", "src\Orleans.Streaming.GCP\Orleans.Streaming.GCP.csproj", "{6E5860C5-44E7-415C-80D6-3ECF15A80796}"
@@ -162,8 +160,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.ServiceFabric", "sr
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RuntimeCodeGen.Tests", "test\RuntimeCodeGen.Tests\RuntimeCodeGen.Tests.csproj", "{E0B8833A-D96E-4E9D-AC0E-E06ADD2D5ED0}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCore.Tests", "test\NetCore.Tests\NetCore.Tests.csproj", "{1F28D680-7B22-4EA7-BA92-163D4FD76F5E}"
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Azure", "Azure", "{4C5D66BF-EE1C-4DD8-8551-D1B7F3768A34}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AWS", "AWS", "{DA8E126B-BCDB-4E8F-BFB9-2DBFD41F8F70}"
@@ -206,18 +202,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Serializers", "Serializers"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Transactions", "Transactions", "{E4550469-BCFB-4F3E-B778-3769DE18F45A}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.CodeGenerator", "src\Orleans.CodeGenerator\Orleans.CodeGenerator.csproj", "{DB0D1909-F63E-4E29-886B-1BB3D4CD9750}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.CodeGenerator.MSBuild", "src\Orleans.CodeGenerator.MSBuild\Orleans.CodeGenerator.MSBuild.csproj", "{E398E494-6FB3-451D-96D1-9AEB7E542A45}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.CodeGenerator.MSBuild.Bootstrap", "src\BootstrapBuild\Orleans.CodeGenerator.MSBuild.Bootstrap\Orleans.CodeGenerator.MSBuild.Bootstrap.csproj", "{31DD8BA1-0172-4A10-9193-954A6CDA54A0}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CodeGeneration", "CodeGeneration", "{D9F12BF9-55AD-4BA3-B850-9A410C287733}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeGenerator.Tests", "test\CodeGeneration\CodeGenerator.Tests\CodeGenerator.Tests.csproj", "{C831C17D-EB49-4237-B86F-638C9A8E9708}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.CodeGenerator.MSBuild.Tasks", "src\Orleans.CodeGenerator.MSBuild.Tasks\Orleans.CodeGenerator.MSBuild.Tasks.csproj", "{5EAE884A-52BE-4AA6-9FCB-AD1C45A9BB7C}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -816,18 +800,6 @@ Global
{8A652779-85EF-48E2-A639-1EED3CE2C39C}.Release|x64.Build.0 = Release|Any CPU
{8A652779-85EF-48E2-A639-1EED3CE2C39C}.Release|x86.ActiveCfg = Release|Any CPU
{8A652779-85EF-48E2-A639-1EED3CE2C39C}.Release|x86.Build.0 = Release|Any CPU
- {A4F61392-36A3-457C-80D0-9CDC48F5922F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A4F61392-36A3-457C-80D0-9CDC48F5922F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A4F61392-36A3-457C-80D0-9CDC48F5922F}.Debug|x64.ActiveCfg = Debug|Any CPU
- {A4F61392-36A3-457C-80D0-9CDC48F5922F}.Debug|x64.Build.0 = Debug|Any CPU
- {A4F61392-36A3-457C-80D0-9CDC48F5922F}.Debug|x86.ActiveCfg = Debug|Any CPU
- {A4F61392-36A3-457C-80D0-9CDC48F5922F}.Debug|x86.Build.0 = Debug|Any CPU
- {A4F61392-36A3-457C-80D0-9CDC48F5922F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A4F61392-36A3-457C-80D0-9CDC48F5922F}.Release|Any CPU.Build.0 = Release|Any CPU
- {A4F61392-36A3-457C-80D0-9CDC48F5922F}.Release|x64.ActiveCfg = Release|Any CPU
- {A4F61392-36A3-457C-80D0-9CDC48F5922F}.Release|x64.Build.0 = Release|Any CPU
- {A4F61392-36A3-457C-80D0-9CDC48F5922F}.Release|x86.ActiveCfg = Release|Any CPU
- {A4F61392-36A3-457C-80D0-9CDC48F5922F}.Release|x86.Build.0 = Release|Any CPU
{1153256E-10C2-4729-ACDC-5DF18A7B92B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1153256E-10C2-4729-ACDC-5DF18A7B92B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1153256E-10C2-4729-ACDC-5DF18A7B92B5}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -1116,18 +1088,6 @@ Global
{E0B8833A-D96E-4E9D-AC0E-E06ADD2D5ED0}.Release|x64.Build.0 = Release|Any CPU
{E0B8833A-D96E-4E9D-AC0E-E06ADD2D5ED0}.Release|x86.ActiveCfg = Release|Any CPU
{E0B8833A-D96E-4E9D-AC0E-E06ADD2D5ED0}.Release|x86.Build.0 = Release|Any CPU
- {1F28D680-7B22-4EA7-BA92-163D4FD76F5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {1F28D680-7B22-4EA7-BA92-163D4FD76F5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {1F28D680-7B22-4EA7-BA92-163D4FD76F5E}.Debug|x64.ActiveCfg = Debug|Any CPU
- {1F28D680-7B22-4EA7-BA92-163D4FD76F5E}.Debug|x64.Build.0 = Debug|Any CPU
- {1F28D680-7B22-4EA7-BA92-163D4FD76F5E}.Debug|x86.ActiveCfg = Debug|Any CPU
- {1F28D680-7B22-4EA7-BA92-163D4FD76F5E}.Debug|x86.Build.0 = Debug|Any CPU
- {1F28D680-7B22-4EA7-BA92-163D4FD76F5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {1F28D680-7B22-4EA7-BA92-163D4FD76F5E}.Release|Any CPU.Build.0 = Release|Any CPU
- {1F28D680-7B22-4EA7-BA92-163D4FD76F5E}.Release|x64.ActiveCfg = Release|Any CPU
- {1F28D680-7B22-4EA7-BA92-163D4FD76F5E}.Release|x64.Build.0 = Release|Any CPU
- {1F28D680-7B22-4EA7-BA92-163D4FD76F5E}.Release|x86.ActiveCfg = Release|Any CPU
- {1F28D680-7B22-4EA7-BA92-163D4FD76F5E}.Release|x86.Build.0 = Release|Any CPU
{CE21A15A-E376-4B81-BDA6-3AB610CFE03A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CE21A15A-E376-4B81-BDA6-3AB610CFE03A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CE21A15A-E376-4B81-BDA6-3AB610CFE03A}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -1272,66 +1232,6 @@ Global
{F23930FE-A219-49E1-8ECB-5A94F271EDC1}.Release|x64.Build.0 = Release|Any CPU
{F23930FE-A219-49E1-8ECB-5A94F271EDC1}.Release|x86.ActiveCfg = Release|Any CPU
{F23930FE-A219-49E1-8ECB-5A94F271EDC1}.Release|x86.Build.0 = Release|Any CPU
- {DB0D1909-F63E-4E29-886B-1BB3D4CD9750}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {DB0D1909-F63E-4E29-886B-1BB3D4CD9750}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {DB0D1909-F63E-4E29-886B-1BB3D4CD9750}.Debug|x64.ActiveCfg = Debug|Any CPU
- {DB0D1909-F63E-4E29-886B-1BB3D4CD9750}.Debug|x64.Build.0 = Debug|Any CPU
- {DB0D1909-F63E-4E29-886B-1BB3D4CD9750}.Debug|x86.ActiveCfg = Debug|Any CPU
- {DB0D1909-F63E-4E29-886B-1BB3D4CD9750}.Debug|x86.Build.0 = Debug|Any CPU
- {DB0D1909-F63E-4E29-886B-1BB3D4CD9750}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {DB0D1909-F63E-4E29-886B-1BB3D4CD9750}.Release|Any CPU.Build.0 = Release|Any CPU
- {DB0D1909-F63E-4E29-886B-1BB3D4CD9750}.Release|x64.ActiveCfg = Release|Any CPU
- {DB0D1909-F63E-4E29-886B-1BB3D4CD9750}.Release|x64.Build.0 = Release|Any CPU
- {DB0D1909-F63E-4E29-886B-1BB3D4CD9750}.Release|x86.ActiveCfg = Release|Any CPU
- {DB0D1909-F63E-4E29-886B-1BB3D4CD9750}.Release|x86.Build.0 = Release|Any CPU
- {E398E494-6FB3-451D-96D1-9AEB7E542A45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E398E494-6FB3-451D-96D1-9AEB7E542A45}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E398E494-6FB3-451D-96D1-9AEB7E542A45}.Debug|x64.ActiveCfg = Debug|Any CPU
- {E398E494-6FB3-451D-96D1-9AEB7E542A45}.Debug|x64.Build.0 = Debug|Any CPU
- {E398E494-6FB3-451D-96D1-9AEB7E542A45}.Debug|x86.ActiveCfg = Debug|Any CPU
- {E398E494-6FB3-451D-96D1-9AEB7E542A45}.Debug|x86.Build.0 = Debug|Any CPU
- {E398E494-6FB3-451D-96D1-9AEB7E542A45}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E398E494-6FB3-451D-96D1-9AEB7E542A45}.Release|Any CPU.Build.0 = Release|Any CPU
- {E398E494-6FB3-451D-96D1-9AEB7E542A45}.Release|x64.ActiveCfg = Release|Any CPU
- {E398E494-6FB3-451D-96D1-9AEB7E542A45}.Release|x64.Build.0 = Release|Any CPU
- {E398E494-6FB3-451D-96D1-9AEB7E542A45}.Release|x86.ActiveCfg = Release|Any CPU
- {E398E494-6FB3-451D-96D1-9AEB7E542A45}.Release|x86.Build.0 = Release|Any CPU
- {31DD8BA1-0172-4A10-9193-954A6CDA54A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {31DD8BA1-0172-4A10-9193-954A6CDA54A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {31DD8BA1-0172-4A10-9193-954A6CDA54A0}.Debug|x64.ActiveCfg = Debug|Any CPU
- {31DD8BA1-0172-4A10-9193-954A6CDA54A0}.Debug|x64.Build.0 = Debug|Any CPU
- {31DD8BA1-0172-4A10-9193-954A6CDA54A0}.Debug|x86.ActiveCfg = Debug|Any CPU
- {31DD8BA1-0172-4A10-9193-954A6CDA54A0}.Debug|x86.Build.0 = Debug|Any CPU
- {31DD8BA1-0172-4A10-9193-954A6CDA54A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {31DD8BA1-0172-4A10-9193-954A6CDA54A0}.Release|Any CPU.Build.0 = Release|Any CPU
- {31DD8BA1-0172-4A10-9193-954A6CDA54A0}.Release|x64.ActiveCfg = Release|Any CPU
- {31DD8BA1-0172-4A10-9193-954A6CDA54A0}.Release|x64.Build.0 = Release|Any CPU
- {31DD8BA1-0172-4A10-9193-954A6CDA54A0}.Release|x86.ActiveCfg = Release|Any CPU
- {31DD8BA1-0172-4A10-9193-954A6CDA54A0}.Release|x86.Build.0 = Release|Any CPU
- {C831C17D-EB49-4237-B86F-638C9A8E9708}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {C831C17D-EB49-4237-B86F-638C9A8E9708}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {C831C17D-EB49-4237-B86F-638C9A8E9708}.Debug|x64.ActiveCfg = Debug|Any CPU
- {C831C17D-EB49-4237-B86F-638C9A8E9708}.Debug|x64.Build.0 = Debug|Any CPU
- {C831C17D-EB49-4237-B86F-638C9A8E9708}.Debug|x86.ActiveCfg = Debug|Any CPU
- {C831C17D-EB49-4237-B86F-638C9A8E9708}.Debug|x86.Build.0 = Debug|Any CPU
- {C831C17D-EB49-4237-B86F-638C9A8E9708}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {C831C17D-EB49-4237-B86F-638C9A8E9708}.Release|Any CPU.Build.0 = Release|Any CPU
- {C831C17D-EB49-4237-B86F-638C9A8E9708}.Release|x64.ActiveCfg = Release|Any CPU
- {C831C17D-EB49-4237-B86F-638C9A8E9708}.Release|x64.Build.0 = Release|Any CPU
- {C831C17D-EB49-4237-B86F-638C9A8E9708}.Release|x86.ActiveCfg = Release|Any CPU
- {C831C17D-EB49-4237-B86F-638C9A8E9708}.Release|x86.Build.0 = Release|Any CPU
- {5EAE884A-52BE-4AA6-9FCB-AD1C45A9BB7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {5EAE884A-52BE-4AA6-9FCB-AD1C45A9BB7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {5EAE884A-52BE-4AA6-9FCB-AD1C45A9BB7C}.Debug|x64.ActiveCfg = Debug|Any CPU
- {5EAE884A-52BE-4AA6-9FCB-AD1C45A9BB7C}.Debug|x64.Build.0 = Debug|Any CPU
- {5EAE884A-52BE-4AA6-9FCB-AD1C45A9BB7C}.Debug|x86.ActiveCfg = Debug|Any CPU
- {5EAE884A-52BE-4AA6-9FCB-AD1C45A9BB7C}.Debug|x86.Build.0 = Debug|Any CPU
- {5EAE884A-52BE-4AA6-9FCB-AD1C45A9BB7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {5EAE884A-52BE-4AA6-9FCB-AD1C45A9BB7C}.Release|Any CPU.Build.0 = Release|Any CPU
- {5EAE884A-52BE-4AA6-9FCB-AD1C45A9BB7C}.Release|x64.ActiveCfg = Release|Any CPU
- {5EAE884A-52BE-4AA6-9FCB-AD1C45A9BB7C}.Release|x64.Build.0 = Release|Any CPU
- {5EAE884A-52BE-4AA6-9FCB-AD1C45A9BB7C}.Release|x86.ActiveCfg = Release|Any CPU
- {5EAE884A-52BE-4AA6-9FCB-AD1C45A9BB7C}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -1389,7 +1289,6 @@ Global
{6BA81672-10EA-4DA7-A620-3D60619FD39E} = {082D25DB-70CA-48F4-93E0-EC3455F494B8}
{7E2B3E56-5DF7-4518-B989-BE0012682C59} = {082D25DB-70CA-48F4-93E0-EC3455F494B8}
{8A652779-85EF-48E2-A639-1EED3CE2C39C} = {2A128E88-B281-4BFB-ADEB-E515437F2385}
- {A4F61392-36A3-457C-80D0-9CDC48F5922F} = {70BCC54E-1618-4742-A079-07588065E361}
{1153256E-10C2-4729-ACDC-5DF18A7B92B5} = {4CD3AA9E-D937-48CA-BB6C-158E12257D23}
{6E5860C5-44E7-415C-80D6-3ECF15A80796} = {FE2E08C6-9C3B-4AEE-AE07-CCA387580D7A}
{EBD697E3-91BE-4844-B3F0-6997300A8C12} = {2A128E88-B281-4BFB-ADEB-E515437F2385}
@@ -1414,7 +1313,6 @@ Global
{DA0FC102-756F-4C1F-8018-FEC5A64F06F6} = {DA8E126B-BCDB-4E8F-BFB9-2DBFD41F8F70}
{814FF01E-1466-4A71-A48F-F40143EF49AA} = {A15BD3B2-513B-449C-A2E9-81DA2DE2FF92}
{E0B8833A-D96E-4E9D-AC0E-E06ADD2D5ED0} = {A6573187-FD0D-4DF7-91D1-03E07E470C0A}
- {1F28D680-7B22-4EA7-BA92-163D4FD76F5E} = {A6573187-FD0D-4DF7-91D1-03E07E470C0A}
{4C5D66BF-EE1C-4DD8-8551-D1B7F3768A34} = {FE2E08C6-9C3B-4AEE-AE07-CCA387580D7A}
{DA8E126B-BCDB-4E8F-BFB9-2DBFD41F8F70} = {FE2E08C6-9C3B-4AEE-AE07-CCA387580D7A}
{CE21A15A-E376-4B81-BDA6-3AB610CFE03A} = {EB2EDE59-5021-42EE-A97A-D59939B39C66}
@@ -1436,12 +1334,6 @@ Global
{70BCC54E-1618-4742-A079-07588065E361} = {A6573187-FD0D-4DF7-91D1-03E07E470C0A}
{CD7EFF05-D1F0-48A1-AE6B-780DC6F7907A} = {082D25DB-70CA-48F4-93E0-EC3455F494B8}
{E4550469-BCFB-4F3E-B778-3769DE18F45A} = {A6573187-FD0D-4DF7-91D1-03E07E470C0A}
- {DB0D1909-F63E-4E29-886B-1BB3D4CD9750} = {4CD3AA9E-D937-48CA-BB6C-158E12257D23}
- {E398E494-6FB3-451D-96D1-9AEB7E542A45} = {4CD3AA9E-D937-48CA-BB6C-158E12257D23}
- {31DD8BA1-0172-4A10-9193-954A6CDA54A0} = {DA143BBE-5D97-4792-8E36-44A3FA727C74}
- {D9F12BF9-55AD-4BA3-B850-9A410C287733} = {A6573187-FD0D-4DF7-91D1-03E07E470C0A}
- {C831C17D-EB49-4237-B86F-638C9A8E9708} = {D9F12BF9-55AD-4BA3-B850-9A410C287733}
- {5EAE884A-52BE-4AA6-9FCB-AD1C45A9BB7C} = {4CD3AA9E-D937-48CA-BB6C-158E12257D23}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7BFB3429-B5BB-4DB1-95B4-67D77A864952}
diff --git a/OrleansCrossPlatform.sln b/OrleansCrossPlatform.sln
index 7106fdfe096..227b504dca4 100644
--- a/OrleansCrossPlatform.sln
+++ b/OrleansCrossPlatform.sln
@@ -46,6 +46,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.Core.Abstractions",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.CodeGeneration.Build", "src\Orleans.CodeGeneration.Build\Orleans.CodeGeneration.Build.csproj", "{345B12A5-C5F3-4AFC-84AA-A8CC00F8D511}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.Core.Bootstrap", "src\BootstrapBuild\Orleans.Core\Orleans.Core.Bootstrap.csproj", "{0CCA4C5C-1D31-4AA9-A7AF-90DD63C16F5B}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.CodeGeneration.Build.Bootstrap", "src\BootstrapBuild\Orleans.CodeGeneration.Build\Orleans.CodeGeneration.Build.Bootstrap.csproj", "{F7D70028-7E3B-48E3-92B9-DB889AE5ABD1}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.CodeGeneration.Bootstrap", "src\BootstrapBuild\Orleans.CodeGeneration\Orleans.CodeGeneration.Bootstrap.csproj", "{9B07237D-651C-497D-9E8D-EADC8FAF26FF}"
+EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.Transactions", "src\Orleans.Transactions\Orleans.Transactions.csproj", "{072B1B88-FE98-4354-86FA-AB6EF80EB9C4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.Transactions.AzureStorage", "src\Azure\Orleans.Transactions.AzureStorage\Orleans.Transactions.AzureStorage.csproj", "{BE7FB595-FA25-4D88-8504-E9D4F9D8183D}"
@@ -86,14 +92,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.Core.Legacy", "src\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.Runtime.Legacy", "src\Orleans.Runtime.Legacy\Orleans.Runtime.Legacy.csproj", "{8422061F-3007-4245-85AA-CF9CFF7F2225}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.CodeGenerator.MSBuild.Bootstrap", "src\BootstrapBuild\Orleans.CodeGenerator.MSBuild.Bootstrap\Orleans.CodeGenerator.MSBuild.Bootstrap.csproj", "{22AFCE0C-EA29-425F-9265-432C3825C887}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.CodeGenerator.MSBuild.Tasks", "src\Orleans.CodeGenerator.MSBuild.Tasks\Orleans.CodeGenerator.MSBuild.Tasks.csproj", "{A12B969E-E06D-46D3-AEFE-FDB76CE9E362}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.CodeGenerator.MSBuild", "src\Orleans.CodeGenerator.MSBuild\Orleans.CodeGenerator.MSBuild.csproj", "{F80AEB5B-12A3-48A9-B87A-1284368E7146}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orleans.CodeGenerator", "src\Orleans.CodeGenerator\Orleans.CodeGenerator.csproj", "{E0BDFBC7-0E9E-4EA5-9739-6A02AF8B8252}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -332,6 +330,42 @@ Global
{345B12A5-C5F3-4AFC-84AA-A8CC00F8D511}.Release|x64.Build.0 = Release|Any CPU
{345B12A5-C5F3-4AFC-84AA-A8CC00F8D511}.Release|x86.ActiveCfg = Release|Any CPU
{345B12A5-C5F3-4AFC-84AA-A8CC00F8D511}.Release|x86.Build.0 = Release|Any CPU
+ {0CCA4C5C-1D31-4AA9-A7AF-90DD63C16F5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0CCA4C5C-1D31-4AA9-A7AF-90DD63C16F5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0CCA4C5C-1D31-4AA9-A7AF-90DD63C16F5B}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {0CCA4C5C-1D31-4AA9-A7AF-90DD63C16F5B}.Debug|x64.Build.0 = Debug|Any CPU
+ {0CCA4C5C-1D31-4AA9-A7AF-90DD63C16F5B}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {0CCA4C5C-1D31-4AA9-A7AF-90DD63C16F5B}.Debug|x86.Build.0 = Debug|Any CPU
+ {0CCA4C5C-1D31-4AA9-A7AF-90DD63C16F5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0CCA4C5C-1D31-4AA9-A7AF-90DD63C16F5B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0CCA4C5C-1D31-4AA9-A7AF-90DD63C16F5B}.Release|x64.ActiveCfg = Release|Any CPU
+ {0CCA4C5C-1D31-4AA9-A7AF-90DD63C16F5B}.Release|x64.Build.0 = Release|Any CPU
+ {0CCA4C5C-1D31-4AA9-A7AF-90DD63C16F5B}.Release|x86.ActiveCfg = Release|Any CPU
+ {0CCA4C5C-1D31-4AA9-A7AF-90DD63C16F5B}.Release|x86.Build.0 = Release|Any CPU
+ {F7D70028-7E3B-48E3-92B9-DB889AE5ABD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F7D70028-7E3B-48E3-92B9-DB889AE5ABD1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F7D70028-7E3B-48E3-92B9-DB889AE5ABD1}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {F7D70028-7E3B-48E3-92B9-DB889AE5ABD1}.Debug|x64.Build.0 = Debug|Any CPU
+ {F7D70028-7E3B-48E3-92B9-DB889AE5ABD1}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {F7D70028-7E3B-48E3-92B9-DB889AE5ABD1}.Debug|x86.Build.0 = Debug|Any CPU
+ {F7D70028-7E3B-48E3-92B9-DB889AE5ABD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F7D70028-7E3B-48E3-92B9-DB889AE5ABD1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F7D70028-7E3B-48E3-92B9-DB889AE5ABD1}.Release|x64.ActiveCfg = Release|Any CPU
+ {F7D70028-7E3B-48E3-92B9-DB889AE5ABD1}.Release|x64.Build.0 = Release|Any CPU
+ {F7D70028-7E3B-48E3-92B9-DB889AE5ABD1}.Release|x86.ActiveCfg = Release|Any CPU
+ {F7D70028-7E3B-48E3-92B9-DB889AE5ABD1}.Release|x86.Build.0 = Release|Any CPU
+ {9B07237D-651C-497D-9E8D-EADC8FAF26FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9B07237D-651C-497D-9E8D-EADC8FAF26FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9B07237D-651C-497D-9E8D-EADC8FAF26FF}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {9B07237D-651C-497D-9E8D-EADC8FAF26FF}.Debug|x64.Build.0 = Debug|Any CPU
+ {9B07237D-651C-497D-9E8D-EADC8FAF26FF}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {9B07237D-651C-497D-9E8D-EADC8FAF26FF}.Debug|x86.Build.0 = Debug|Any CPU
+ {9B07237D-651C-497D-9E8D-EADC8FAF26FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9B07237D-651C-497D-9E8D-EADC8FAF26FF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9B07237D-651C-497D-9E8D-EADC8FAF26FF}.Release|x64.ActiveCfg = Release|Any CPU
+ {9B07237D-651C-497D-9E8D-EADC8FAF26FF}.Release|x64.Build.0 = Release|Any CPU
+ {9B07237D-651C-497D-9E8D-EADC8FAF26FF}.Release|x86.ActiveCfg = Release|Any CPU
+ {9B07237D-651C-497D-9E8D-EADC8FAF26FF}.Release|x86.Build.0 = Release|Any CPU
{072B1B88-FE98-4354-86FA-AB6EF80EB9C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{072B1B88-FE98-4354-86FA-AB6EF80EB9C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{072B1B88-FE98-4354-86FA-AB6EF80EB9C4}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -536,54 +570,6 @@ Global
{8422061F-3007-4245-85AA-CF9CFF7F2225}.Release|x64.Build.0 = Release|Any CPU
{8422061F-3007-4245-85AA-CF9CFF7F2225}.Release|x86.ActiveCfg = Release|Any CPU
{8422061F-3007-4245-85AA-CF9CFF7F2225}.Release|x86.Build.0 = Release|Any CPU
- {22AFCE0C-EA29-425F-9265-432C3825C887}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {22AFCE0C-EA29-425F-9265-432C3825C887}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {22AFCE0C-EA29-425F-9265-432C3825C887}.Debug|x64.ActiveCfg = Debug|Any CPU
- {22AFCE0C-EA29-425F-9265-432C3825C887}.Debug|x64.Build.0 = Debug|Any CPU
- {22AFCE0C-EA29-425F-9265-432C3825C887}.Debug|x86.ActiveCfg = Debug|Any CPU
- {22AFCE0C-EA29-425F-9265-432C3825C887}.Debug|x86.Build.0 = Debug|Any CPU
- {22AFCE0C-EA29-425F-9265-432C3825C887}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {22AFCE0C-EA29-425F-9265-432C3825C887}.Release|Any CPU.Build.0 = Release|Any CPU
- {22AFCE0C-EA29-425F-9265-432C3825C887}.Release|x64.ActiveCfg = Release|Any CPU
- {22AFCE0C-EA29-425F-9265-432C3825C887}.Release|x64.Build.0 = Release|Any CPU
- {22AFCE0C-EA29-425F-9265-432C3825C887}.Release|x86.ActiveCfg = Release|Any CPU
- {22AFCE0C-EA29-425F-9265-432C3825C887}.Release|x86.Build.0 = Release|Any CPU
- {A12B969E-E06D-46D3-AEFE-FDB76CE9E362}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A12B969E-E06D-46D3-AEFE-FDB76CE9E362}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A12B969E-E06D-46D3-AEFE-FDB76CE9E362}.Debug|x64.ActiveCfg = Debug|Any CPU
- {A12B969E-E06D-46D3-AEFE-FDB76CE9E362}.Debug|x64.Build.0 = Debug|Any CPU
- {A12B969E-E06D-46D3-AEFE-FDB76CE9E362}.Debug|x86.ActiveCfg = Debug|Any CPU
- {A12B969E-E06D-46D3-AEFE-FDB76CE9E362}.Debug|x86.Build.0 = Debug|Any CPU
- {A12B969E-E06D-46D3-AEFE-FDB76CE9E362}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A12B969E-E06D-46D3-AEFE-FDB76CE9E362}.Release|Any CPU.Build.0 = Release|Any CPU
- {A12B969E-E06D-46D3-AEFE-FDB76CE9E362}.Release|x64.ActiveCfg = Release|Any CPU
- {A12B969E-E06D-46D3-AEFE-FDB76CE9E362}.Release|x64.Build.0 = Release|Any CPU
- {A12B969E-E06D-46D3-AEFE-FDB76CE9E362}.Release|x86.ActiveCfg = Release|Any CPU
- {A12B969E-E06D-46D3-AEFE-FDB76CE9E362}.Release|x86.Build.0 = Release|Any CPU
- {F80AEB5B-12A3-48A9-B87A-1284368E7146}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {F80AEB5B-12A3-48A9-B87A-1284368E7146}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {F80AEB5B-12A3-48A9-B87A-1284368E7146}.Debug|x64.ActiveCfg = Debug|Any CPU
- {F80AEB5B-12A3-48A9-B87A-1284368E7146}.Debug|x64.Build.0 = Debug|Any CPU
- {F80AEB5B-12A3-48A9-B87A-1284368E7146}.Debug|x86.ActiveCfg = Debug|Any CPU
- {F80AEB5B-12A3-48A9-B87A-1284368E7146}.Debug|x86.Build.0 = Debug|Any CPU
- {F80AEB5B-12A3-48A9-B87A-1284368E7146}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {F80AEB5B-12A3-48A9-B87A-1284368E7146}.Release|Any CPU.Build.0 = Release|Any CPU
- {F80AEB5B-12A3-48A9-B87A-1284368E7146}.Release|x64.ActiveCfg = Release|Any CPU
- {F80AEB5B-12A3-48A9-B87A-1284368E7146}.Release|x64.Build.0 = Release|Any CPU
- {F80AEB5B-12A3-48A9-B87A-1284368E7146}.Release|x86.ActiveCfg = Release|Any CPU
- {F80AEB5B-12A3-48A9-B87A-1284368E7146}.Release|x86.Build.0 = Release|Any CPU
- {E0BDFBC7-0E9E-4EA5-9739-6A02AF8B8252}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E0BDFBC7-0E9E-4EA5-9739-6A02AF8B8252}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E0BDFBC7-0E9E-4EA5-9739-6A02AF8B8252}.Debug|x64.ActiveCfg = Debug|Any CPU
- {E0BDFBC7-0E9E-4EA5-9739-6A02AF8B8252}.Debug|x64.Build.0 = Debug|Any CPU
- {E0BDFBC7-0E9E-4EA5-9739-6A02AF8B8252}.Debug|x86.ActiveCfg = Debug|Any CPU
- {E0BDFBC7-0E9E-4EA5-9739-6A02AF8B8252}.Debug|x86.Build.0 = Debug|Any CPU
- {E0BDFBC7-0E9E-4EA5-9739-6A02AF8B8252}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E0BDFBC7-0E9E-4EA5-9739-6A02AF8B8252}.Release|Any CPU.Build.0 = Release|Any CPU
- {E0BDFBC7-0E9E-4EA5-9739-6A02AF8B8252}.Release|x64.ActiveCfg = Release|Any CPU
- {E0BDFBC7-0E9E-4EA5-9739-6A02AF8B8252}.Release|x64.Build.0 = Release|Any CPU
- {E0BDFBC7-0E9E-4EA5-9739-6A02AF8B8252}.Release|x86.ActiveCfg = Release|Any CPU
- {E0BDFBC7-0E9E-4EA5-9739-6A02AF8B8252}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -609,6 +595,9 @@ Global
{6E5860C5-44E7-415C-80D6-3ECF15A80796} = {FE2E08C6-9C3B-4AEE-AE07-CCA387580D7A}
{73514686-D25D-478B-9943-A86F6B0F3A37} = {4CD3AA9E-D937-48CA-BB6C-158E12257D23}
{345B12A5-C5F3-4AFC-84AA-A8CC00F8D511} = {4CD3AA9E-D937-48CA-BB6C-158E12257D23}
+ {0CCA4C5C-1D31-4AA9-A7AF-90DD63C16F5B} = {DA143BBE-5D97-4792-8E36-44A3FA727C74}
+ {F7D70028-7E3B-48E3-92B9-DB889AE5ABD1} = {DA143BBE-5D97-4792-8E36-44A3FA727C74}
+ {9B07237D-651C-497D-9E8D-EADC8FAF26FF} = {DA143BBE-5D97-4792-8E36-44A3FA727C74}
{072B1B88-FE98-4354-86FA-AB6EF80EB9C4} = {4CD3AA9E-D937-48CA-BB6C-158E12257D23}
{BE7FB595-FA25-4D88-8504-E9D4F9D8183D} = {4C5D66BF-EE1C-4DD8-8551-D1B7F3768A34}
{E9A8A1F9-1943-45E2-9B9C-1E51A9154D76} = {4C5D66BF-EE1C-4DD8-8551-D1B7F3768A34}
@@ -629,10 +618,6 @@ Global
{EB2EDE59-5021-42EE-A97A-D59939B39C66} = {FE2E08C6-9C3B-4AEE-AE07-CCA387580D7A}
{9D5F4B89-3C59-4B21-A862-ACA123B149F4} = {4CD3AA9E-D937-48CA-BB6C-158E12257D23}
{8422061F-3007-4245-85AA-CF9CFF7F2225} = {4CD3AA9E-D937-48CA-BB6C-158E12257D23}
- {22AFCE0C-EA29-425F-9265-432C3825C887} = {DA143BBE-5D97-4792-8E36-44A3FA727C74}
- {A12B969E-E06D-46D3-AEFE-FDB76CE9E362} = {4CD3AA9E-D937-48CA-BB6C-158E12257D23}
- {F80AEB5B-12A3-48A9-B87A-1284368E7146} = {4CD3AA9E-D937-48CA-BB6C-158E12257D23}
- {E0BDFBC7-0E9E-4EA5-9739-6A02AF8B8252} = {4CD3AA9E-D937-48CA-BB6C-158E12257D23}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7BFB3429-B5BB-4DB1-95B4-67D77A864952}
diff --git a/src/Azure/Orleans.Clustering.ServiceFabric/Orleans.Clustering.ServiceFabric.csproj b/src/Azure/Orleans.Clustering.ServiceFabric/Orleans.Clustering.ServiceFabric.csproj
index b517ccc32ae..f38df6c82b6 100644
--- a/src/Azure/Orleans.Clustering.ServiceFabric/Orleans.Clustering.ServiceFabric.csproj
+++ b/src/Azure/Orleans.Clustering.ServiceFabric/Orleans.Clustering.ServiceFabric.csproj
@@ -7,7 +7,7 @@
- netstandard2.0
+ net462
Orleans.Clustering.ServiceFabric
Orleans.Clustering.ServiceFabric
x64
diff --git a/src/Azure/Orleans.Hosting.AzureCloudServices/Orleans.Hosting.AzureCloudServices.csproj b/src/Azure/Orleans.Hosting.AzureCloudServices/Orleans.Hosting.AzureCloudServices.csproj
index b85c6702b8f..f58a785a762 100644
--- a/src/Azure/Orleans.Hosting.AzureCloudServices/Orleans.Hosting.AzureCloudServices.csproj
+++ b/src/Azure/Orleans.Hosting.AzureCloudServices/Orleans.Hosting.AzureCloudServices.csproj
@@ -18,6 +18,7 @@
+
diff --git a/src/Azure/Orleans.Hosting.ServiceFabric/Orleans.Hosting.ServiceFabric.csproj b/src/Azure/Orleans.Hosting.ServiceFabric/Orleans.Hosting.ServiceFabric.csproj
index a721f56358e..cadb4de8e98 100644
--- a/src/Azure/Orleans.Hosting.ServiceFabric/Orleans.Hosting.ServiceFabric.csproj
+++ b/src/Azure/Orleans.Hosting.ServiceFabric/Orleans.Hosting.ServiceFabric.csproj
@@ -7,7 +7,7 @@
- netstandard2.0
+ net462
Orleans.Hosting.ServiceFabric
Orleans.Hosting.ServiceFabric
x64
diff --git a/src/Azure/Orleans.ServiceFabric/Orleans.ServiceFabric.csproj b/src/Azure/Orleans.ServiceFabric/Orleans.ServiceFabric.csproj
index 9f5e4516556..c8ae4a41beb 100644
--- a/src/Azure/Orleans.ServiceFabric/Orleans.ServiceFabric.csproj
+++ b/src/Azure/Orleans.ServiceFabric/Orleans.ServiceFabric.csproj
@@ -5,7 +5,7 @@
Metapackage providing support for hosing Microsoft Orleans on Service Fabric.
$(PackageTags) Azure ServiceFabric
false
- netstandard2.0
+ net462
x64
diff --git a/src/BootstrapBuild/Orleans.CodeGeneration.Build/Orleans.CodeGeneration.Build.Bootstrap.csproj b/src/BootstrapBuild/Orleans.CodeGeneration.Build/Orleans.CodeGeneration.Build.Bootstrap.csproj
index e66c7651398..ad7f1ce3939 100644
--- a/src/BootstrapBuild/Orleans.CodeGeneration.Build/Orleans.CodeGeneration.Build.Bootstrap.csproj
+++ b/src/BootstrapBuild/Orleans.CodeGeneration.Build/Orleans.CodeGeneration.Build.Bootstrap.csproj
@@ -1,7 +1,6 @@
- net461
- netcoreapp2.0
+ net462
Orleans.CodeGeneration.Build
Exe
Microsoft.Orleans.CodeGeneration.Build
diff --git a/src/BootstrapBuild/Orleans.CodeGeneration/Orleans.CodeGeneration.Bootstrap.csproj b/src/BootstrapBuild/Orleans.CodeGeneration/Orleans.CodeGeneration.Bootstrap.csproj
index 5301eb2ec18..a1d13d627c4 100644
--- a/src/BootstrapBuild/Orleans.CodeGeneration/Orleans.CodeGeneration.Bootstrap.csproj
+++ b/src/BootstrapBuild/Orleans.CodeGeneration/Orleans.CodeGeneration.Bootstrap.csproj
@@ -19,7 +19,7 @@
-
+
diff --git a/src/BootstrapBuild/Orleans.CodeGenerator.MSBuild.Bootstrap/Orleans.CodeGenerator.MSBuild.Bootstrap.csproj b/src/BootstrapBuild/Orleans.CodeGenerator.MSBuild.Bootstrap/Orleans.CodeGenerator.MSBuild.Bootstrap.csproj
index 06e4bbdf9a8..42133e98045 100644
--- a/src/BootstrapBuild/Orleans.CodeGenerator.MSBuild.Bootstrap/Orleans.CodeGenerator.MSBuild.Bootstrap.csproj
+++ b/src/BootstrapBuild/Orleans.CodeGenerator.MSBuild.Bootstrap/Orleans.CodeGenerator.MSBuild.Bootstrap.csproj
@@ -1,7 +1,7 @@
- netcoreapp2.0
+ net462
Exe
false
true
diff --git a/src/Orleans.CodeGeneration.Build/Orleans.CodeGeneration.Build.csproj b/src/Orleans.CodeGeneration.Build/Orleans.CodeGeneration.Build.csproj
index d06ac7d2a1a..1cea65866ba 100644
--- a/src/Orleans.CodeGeneration.Build/Orleans.CodeGeneration.Build.csproj
+++ b/src/Orleans.CodeGeneration.Build/Orleans.CodeGeneration.Build.csproj
@@ -8,8 +8,7 @@
- netcoreapp2.0;netcoreapp2.1;net461
- netcoreapp2.0;netcoreapp2.1
+ net462
Exe
true
tasks
diff --git a/src/Orleans.CodeGeneration.Build/build/Microsoft.Orleans.OrleansCodeGenerator.Build.targets b/src/Orleans.CodeGeneration.Build/build/Microsoft.Orleans.OrleansCodeGenerator.Build.targets
index 7ca9a0f7417..3b606c668a5 100644
--- a/src/Orleans.CodeGeneration.Build/build/Microsoft.Orleans.OrleansCodeGenerator.Build.targets
+++ b/src/Orleans.CodeGeneration.Build/build/Microsoft.Orleans.OrleansCodeGenerator.Build.targets
@@ -12,12 +12,7 @@
- $(MSBuildThisFileDirectory)..\tasks\netcoreapp2.0\Orleans.CodeGeneration.Build.dll
- $(MSBuildThisFileDirectory)..\tasks\netcoreapp2.1\Orleans.CodeGeneration.Build.dll
- $(MSBuildThisFileDirectory)..\tasks\net461\Orleans.CodeGeneration.Build.exe
-
- $(CoreAssembly20)
- $(CoreAssembly21)
+ $(MSBuildThisFileDirectory)..\tasks\net462\Orleans.CodeGeneration.Build.exe
$(CoreAssembly20)
diff --git a/src/Orleans.CodeGeneration/FeaturePopulatorGenerator.cs b/src/Orleans.CodeGeneration/FeaturePopulatorGenerator.cs
index 02bd9ef8c0c..b539648860e 100644
--- a/src/Orleans.CodeGeneration/FeaturePopulatorGenerator.cs
+++ b/src/Orleans.CodeGeneration/FeaturePopulatorGenerator.cs
@@ -103,7 +103,7 @@ private static MemberDeclarationSyntax GeneratePopulateMethod(SerializationTypeD
var featureParameter = interfaceMethod.GetParameters()[0].Name.ToIdentifierName();
var bodyStatements = new List();
- var addSerializerTypeMethod = TypeUtils.Method((SerializerFeature _) => _.AddSerializerType(default(Type), default(Type), true));
+ var addSerializerTypeMethod = TypeUtils.Method((SerializerFeature _) => _.AddSerializerType(default(Type), default(Type)));
foreach (var serializerType in typeDescriptions.SerializerTypes)
{
bodyStatements.Add(
diff --git a/src/Orleans.CodeGeneration/Orleans.CodeGeneration.csproj b/src/Orleans.CodeGeneration/Orleans.CodeGeneration.csproj
index 2e66aa9cfdc..f3d564ee9de 100644
--- a/src/Orleans.CodeGeneration/Orleans.CodeGeneration.csproj
+++ b/src/Orleans.CodeGeneration/Orleans.CodeGeneration.csproj
@@ -6,7 +6,7 @@
-
+
diff --git a/src/Orleans.CodeGenerator.MSBuild.Tasks/DotNetMuxer.cs b/src/Orleans.CodeGenerator.MSBuild.Tasks/DotNetMuxer.cs
deleted file mode 100644
index ec8d7018ed4..00000000000
--- a/src/Orleans.CodeGenerator.MSBuild.Tasks/DotNetMuxer.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.IO;
-using System.Runtime.InteropServices;
-
-namespace Orleans.CodeGenerator.MSBuild.Tasks
-{
- ///
- /// Utilities for finding the "dotnet.exe" file from the currently running .NET Core application
- ///
- internal static class DotNetMuxer
- {
- private const string MuxerName = "dotnet";
-
- static DotNetMuxer()
- {
- MuxerPath = TryFindMuxerPath();
- }
-
- ///
- /// The full filepath to the .NET Core muxer.
- ///
- public static string MuxerPath { get; }
-
- ///
- /// Finds the full filepath to the .NET Core muxer,
- /// or returns a string containing the default name of the .NET Core muxer ('dotnet').
- ///
- /// The path or a string named 'dotnet'.
- public static string MuxerPathOrDefault()
- => MuxerPath ?? MuxerName;
-
- private static string TryFindMuxerPath()
- {
- var fileName = MuxerName;
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
- {
- fileName += ".exe";
- }
-
- var mainModule = Process.GetCurrentProcess().MainModule;
- if (!string.IsNullOrEmpty(mainModule?.FileName)
- && Path.GetFileName(mainModule.FileName).Equals(fileName, StringComparison.OrdinalIgnoreCase))
- {
- return mainModule.FileName;
- }
-
- return null;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator.MSBuild.Tasks/GetDotNetHost.cs b/src/Orleans.CodeGenerator.MSBuild.Tasks/GetDotNetHost.cs
deleted file mode 100644
index 10272712c15..00000000000
--- a/src/Orleans.CodeGenerator.MSBuild.Tasks/GetDotNetHost.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using Microsoft.Build.Framework;
-using MSBuildTask = Microsoft.Build.Utilities.Task;
-
-namespace Orleans.CodeGenerator.MSBuild.Tasks
-{
- public class GetDotNetHost : MSBuildTask
- {
- [Output]
- public string DotNetHost { get; set; }
-
- public override bool Execute()
- {
- this.DotNetHost = TryFindDotNetExePath();
- return true;
- }
-
- private static string TryFindDotNetExePath() => DotNetMuxer.MuxerPathOrDefault();
- }
-}
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator.MSBuild.Tasks/Orleans.CodeGenerator.MSBuild.Tasks.csproj b/src/Orleans.CodeGenerator.MSBuild.Tasks/Orleans.CodeGenerator.MSBuild.Tasks.csproj
index aa6846e04ee..2f0795d555a 100644
--- a/src/Orleans.CodeGenerator.MSBuild.Tasks/Orleans.CodeGenerator.MSBuild.Tasks.csproj
+++ b/src/Orleans.CodeGenerator.MSBuild.Tasks/Orleans.CodeGenerator.MSBuild.Tasks.csproj
@@ -1,6 +1,6 @@
- netstandard2.0
+ net462
diff --git a/src/Orleans.CodeGenerator.MSBuild/AssemblyResolver.cs b/src/Orleans.CodeGenerator.MSBuild/AssemblyResolver.cs
deleted file mode 100644
index 5b95a38bb46..00000000000
--- a/src/Orleans.CodeGenerator.MSBuild/AssemblyResolver.cs
+++ /dev/null
@@ -1,131 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-using System.Runtime.Loader;
-using Microsoft.Extensions.DependencyModel;
-using Microsoft.Extensions.DependencyModel.Resolution;
-#if NETCOREAPP2_0
-
-#endif
-
-namespace Microsoft.Orleans.CodeGenerator.MSBuild
-{
- ///
- /// Simple class that loads the reference assemblies upon the AppDomain.AssemblyResolve
- ///
- internal class AssemblyResolver : IDisposable
- {
- private readonly ICompilationAssemblyResolver assemblyResolver;
-
- private readonly DependencyContext resolverRependencyContext;
-#if NETCOREAPP2_0
- private readonly AssemblyLoadContext loadContext;
-#endif
-
- public AssemblyResolver()
- {
- this.resolverRependencyContext = DependencyContext.Load(typeof(AssemblyResolver).Assembly);
- var codegenPath = Path.GetDirectoryName(new Uri(typeof(AssemblyResolver).Assembly.CodeBase).LocalPath);
- this.assemblyResolver = new CompositeCompilationAssemblyResolver(
- new ICompilationAssemblyResolver[]
- {
- new AppBaseCompilationAssemblyResolver(codegenPath),
- new ReferenceAssemblyPathResolver(),
- new PackageCompilationAssemblyResolver()
- });
-
- AppDomain.CurrentDomain.AssemblyResolve += this.ResolveAssembly;
-#if NETCOREAPP2_0
- this.loadContext = AssemblyLoadContext.GetLoadContext(typeof(AssemblyResolver).Assembly);
- this.loadContext.Resolving += this.AssemblyLoadContextResolving;
- if (this.loadContext != AssemblyLoadContext.Default)
- {
- AssemblyLoadContext.Default.Resolving += this.AssemblyLoadContextResolving;
- }
-#endif
- }
-
- public void Dispose()
- {
- AppDomain.CurrentDomain.AssemblyResolve -= this.ResolveAssembly;
-
-#if NETCOREAPP2_0
- this.loadContext.Resolving -= this.AssemblyLoadContextResolving;
- if (this.loadContext != AssemblyLoadContext.Default)
- {
- AssemblyLoadContext.Default.Resolving -= this.AssemblyLoadContextResolving;
- }
-#endif
- }
-
- ///
- /// Handles System.AppDomain.AssemblyResolve event of an System.AppDomain
- ///
- /// The source of the event.
- /// The event data.
- /// The assembly that resolves the type, assembly, or resource;
- /// or null if theassembly cannot be resolved.
- ///
- public Assembly ResolveAssembly(object sender, ResolveEventArgs args)
- {
- return this.AssemblyLoadContextResolving(null, new AssemblyName(args.Name));
- }
-
- public Assembly AssemblyLoadContextResolving(AssemblyLoadContext context, AssemblyName name)
- {
- // Attempt to resolve the library from one of the dependency contexts.
- var library = this.resolverRependencyContext?.RuntimeLibraries?.FirstOrDefault(NamesMatch);
- if (library == null) return null;
-
- var wrapper = new CompilationLibrary(
- library.Type,
- library.Name,
- library.Version,
- library.Hash,
- library.RuntimeAssemblyGroups.SelectMany(g => g.AssetPaths),
- library.Dependencies,
- library.Serviceable);
-
- var assemblies = new List();
- if (this.assemblyResolver.TryResolveAssemblyPaths(wrapper, assemblies))
- {
- foreach (var asm in assemblies)
- {
- var assembly = this.TryLoadAssemblyFromPath(asm);
- if (assembly != null) return assembly;
- }
- }
-
- return null;
-
- bool NamesMatch(RuntimeLibrary runtime)
- {
- return string.Equals(runtime.Name, name.Name, StringComparison.OrdinalIgnoreCase);
- }
- }
-
- private Assembly TryLoadAssemblyFromPath(string path)
- {
- try
- {
-#if NETCOREAPP2_0
- return this.loadContext.LoadFromAssemblyPath(path);
-#else
- return Assembly.LoadFrom(path);
-#endif
- }
- catch
- {
- return null;
- }
- }
-
-#if !NETCOREAPP2_0
- internal class AssemblyLoadContext
- {
- }
-#endif
- }
-}
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator.MSBuild/CodeGeneratorCommand.cs b/src/Orleans.CodeGenerator.MSBuild/CodeGeneratorCommand.cs
deleted file mode 100644
index 69ffe071de0..00000000000
--- a/src/Orleans.CodeGenerator.MSBuild/CodeGeneratorCommand.cs
+++ /dev/null
@@ -1,229 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.Text;
-using Microsoft.Extensions.Logging;
-
-namespace Orleans.CodeGenerator.MSBuild
-{
- public class CodeGeneratorCommand
- {
- private const string AbstractionsAssemblyShortName = "Orleans.Core.Abstractions";
-
- private static readonly int[] SuppressCompilerWarnings =
- {
- 162, // CS0162 - Unreachable code detected.
- 219, // CS0219 - The variable 'V' is assigned but its value is never used.
- 414, // CS0414 - The private field 'F' is assigned but its value is never used.
- 618, // CS0616 - Member is obsolete.
- 649, // CS0649 - Field 'F' is never assigned to, and will always have its default value.
- 693, // CS0693 - Type parameter 'type parameter' has the same name as the type parameter from outer type 'T'
- 1591, // CS1591 - Missing XML comment for publicly visible type or member 'Type_or_Member'
- 1998 // CS1998 - This async method lacks 'await' operators and will run synchronously
- };
-
- public ILogger Log { get; set; }
-
- ///
- /// The MSBuild project path.
- ///
- public string ProjectPath { get; set; }
-
- ///
- /// The optional ProjectGuid.
- ///
- public string ProjectGuid { get; set; }
-
- ///
- /// The output type, such as Exe, or Library.
- ///
- public string OutputType { get; set; }
-
- ///
- /// The target path of the compilation.
- ///
- public string TargetPath { get; set; }
-
- ///
- /// The source files.
- ///
- public List Compile { get; } = new List();
-
- ///
- /// The libraries referenced by the project.
- ///
- public List Reference { get; } = new List();
-
- ///
- /// The defined constants for the project.
- ///
- public List DefineConstants { get; } = new List();
-
- ///
- /// The file which holds the generated code.
- ///
- public string CodeGenOutputFile { get; set; }
-
- ///
- /// The project's assembly name, important for id calculations.
- ///
- public string AssemblyName { get; set; }
-
- public async Task Execute(CancellationToken cancellationToken)
- {
- var stopwatch = Stopwatch.StartNew();
- var projectName = Path.GetFileNameWithoutExtension(ProjectPath);
- var projectId = !string.IsNullOrEmpty(ProjectGuid) && Guid.TryParse(ProjectGuid, out var projectIdGuid)
- ? ProjectId.CreateFromSerialized(projectIdGuid)
- : ProjectId.CreateNewId();
-
- this.Log.LogDebug($"ProjectGuid: {ProjectGuid}");
- this.Log.LogDebug($"ProjectID: {projectId}");
-
- var languageName = GetLanguageName(ProjectPath);
-
- var projectInfo = ProjectInfo.Create(
- projectId,
- VersionStamp.Create(),
- projectName,
- AssemblyName,
- languageName,
- ProjectPath,
- TargetPath,
- CreateCompilationOptions(this),
- documents: GetDocuments(Compile, projectId),
- metadataReferences: GetMetadataReferences(Reference),
- parseOptions: new CSharpParseOptions(preprocessorSymbols: this.DefineConstants)
- );
-
- this.Log.LogDebug($"Project: {projectInfo}");
-
- var workspace = new AdhocWorkspace();
- workspace.AddProject(projectInfo);
-
- var project = workspace.CurrentSolution.Projects.Single();
- this.Log.LogInformation($"Workspace creation completed in {stopwatch.ElapsedMilliseconds}ms.");
- stopwatch.Restart();
-
- var compilation = await project.GetCompilationAsync(cancellationToken);
- this.Log.LogInformation($"GetCompilation completed in {stopwatch.ElapsedMilliseconds}ms.");
- stopwatch.Restart();
-
- if (compilation.ReferencedAssemblyNames.All(name => name.Name != AbstractionsAssemblyShortName))
- {
- this.Log.LogWarning($"Assembly {compilation.AssemblyName} does not reference {AbstractionsAssemblyShortName} (references: {string.Join(", ", compilation.ReferencedAssemblyNames)})");
- return false;
- }
-
- var generator = new CodeGenerator(compilation, this.Log);
- var syntax = generator.GenerateCode(cancellationToken);
- this.Log.LogInformation($"GenerateCode completed in {stopwatch.ElapsedMilliseconds}ms.");
- stopwatch.Restart();
-
- var normalized = syntax.NormalizeWhitespace();
- this.Log.LogInformation($"NormalizeWhitespace completed in {stopwatch.ElapsedMilliseconds}ms.");
- stopwatch.Restart();
-
- var sourceBuilder = new StringBuilder();
- sourceBuilder.AppendLine("// ");
- sourceBuilder.AppendLine("#if !EXCLUDE_GENERATED_CODE");
- foreach (var warningNum in SuppressCompilerWarnings) sourceBuilder.AppendLine($"#pragma warning disable {warningNum}");
- sourceBuilder.AppendLine(normalized.ToFullString());
- foreach (var warningNum in SuppressCompilerWarnings) sourceBuilder.AppendLine($"#pragma warning restore {warningNum}");
- sourceBuilder.AppendLine("#endif");
- var source = sourceBuilder.ToString();
-
- this.Log.LogInformation($"Generate source from syntax completed in {stopwatch.ElapsedMilliseconds}ms.");
- stopwatch.Restart();
-
- if (File.Exists(this.CodeGenOutputFile))
- {
- using (var reader = new StreamReader(this.CodeGenOutputFile))
- {
- var existing = await reader.ReadToEndAsync();
- if (string.Equals(source, existing, StringComparison.Ordinal))
- {
- this.Log.LogInformation("Generated code matches existing code.");
- return true;
- }
- }
- }
-
- using (var sourceWriter = new StreamWriter(this.CodeGenOutputFile))
- {
- await sourceWriter.WriteAsync(source);
- }
-
- this.Log.LogInformation($"Write source to disk completed in {stopwatch.ElapsedMilliseconds}ms.");
-
- return true;
- }
-
- private static IEnumerable GetDocuments(List sources, ProjectId projectId) =>
- sources
- ?.Where(File.Exists)
- .Select(x => DocumentInfo.Create(
- DocumentId.CreateNewId(projectId),
- Path.GetFileName(x),
- loader: TextLoader.From(
- TextAndVersion.Create(
- SourceText.From(File.ReadAllText(x)), VersionStamp.Create())),
- filePath: x))
- ?? Array.Empty();
-
- private static IEnumerable GetMetadataReferences(List references) =>
- references
- ?.Where(File.Exists)
- .Select(x => MetadataReference.CreateFromFile(x))
- ?? (IEnumerable)Array.Empty();
-
-
- private static string GetLanguageName(string projectPath)
- {
- switch (Path.GetExtension(projectPath))
- {
- case ".csproj":
- return LanguageNames.CSharp;
- case string ext when !string.IsNullOrWhiteSpace(ext):
- throw new NotSupportedException($"Projects of type {ext} are not supported.");
- default:
- throw new InvalidOperationException("Could not determine supported language from project path");
-
- }
- }
-
- private static CompilationOptions CreateCompilationOptions(CodeGeneratorCommand command)
- {
- OutputKind kind;
- switch (command.OutputType)
- {
- case "Exe":
- kind = OutputKind.ConsoleApplication;
- break;
- case "Module":
- kind = OutputKind.NetModule;
- break;
- case "Winexe":
- kind = OutputKind.WindowsApplication;
- break;
- default:
- case "Library":
- kind = OutputKind.DynamicallyLinkedLibrary;
- break;
- }
-
- return new CSharpCompilationOptions(kind)
- .WithMetadataImportOptions(MetadataImportOptions.All)
- .WithAllowUnsafe(true)
- .WithConcurrentBuild(true)
- .WithOptimizationLevel(OptimizationLevel.Debug);
- }
- }
-}
diff --git a/src/Orleans.CodeGenerator.MSBuild/Directory.Build.props b/src/Orleans.CodeGenerator.MSBuild/Directory.Build.props
deleted file mode 100644
index 2a2f64ff80d..00000000000
--- a/src/Orleans.CodeGenerator.MSBuild/Directory.Build.props
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
- <_ParentDirectoryBuildPropsPath Condition="'$(_DirectoryBuildPropsFile)' != ''">$([System.IO.Path]::Combine('..', '$(_DirectoryBuildPropsFile)'))
-
-
-
-
-
- false
-
-
-
- true
-
-
-
-
- true
- https://github.com/dotnet/orleans
-
-
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator.MSBuild/LogFormatter.cs b/src/Orleans.CodeGenerator.MSBuild/LogFormatter.cs
deleted file mode 100644
index e2ef7e88fb5..00000000000
--- a/src/Orleans.CodeGenerator.MSBuild/LogFormatter.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-using System;
-using System.Reflection;
-using System.Text;
-
-namespace Microsoft.Orleans.CodeGenerator.MSBuild
-{
- internal static class LogFormatter
- {
- ///
- /// Utility function to convert an exception into printable format, including expanding and formatting any nested sub-expressions.
- ///
- /// The exception to be printed.
- /// Formatted string representation of the exception, including expanding and formatting any nested sub-expressions.
- public static string PrintException(Exception exception)
- {
- return exception == null ? String.Empty : PrintException_Helper(exception, 0, true);
- }
-
- private static string PrintException_Helper(Exception exception, int level, bool includeStackTrace)
- {
- if (exception == null) return String.Empty;
- var sb = new StringBuilder();
- sb.Append(PrintOneException(exception, level, includeStackTrace));
- if (exception is ReflectionTypeLoadException loadException)
- {
- var loaderExceptions = loadException.LoaderExceptions;
- if (loaderExceptions == null || loaderExceptions.Length == 0)
- {
- sb.Append("No LoaderExceptions found");
- }
- else
- {
- foreach (Exception inner in loaderExceptions)
- {
- // call recursively on all loader exceptions. Same level for all.
- sb.Append(PrintException_Helper(inner, level + 1, includeStackTrace));
- }
- }
- }
- else if (exception is AggregateException)
- {
- var innerExceptions = ((AggregateException)exception).InnerExceptions;
- if (innerExceptions == null) return sb.ToString();
-
- foreach (Exception inner in innerExceptions)
- {
- // call recursively on all inner exceptions. Same level for all.
- sb.Append(PrintException_Helper(inner, level + 1, includeStackTrace));
- }
- }
- else if (exception.InnerException != null)
- {
- // call recursively on a single inner exception.
- sb.Append(PrintException_Helper(exception.InnerException, level + 1, includeStackTrace));
- }
- return sb.ToString();
- }
-
- private static string PrintOneException(Exception exception, int level, bool includeStackTrace)
- {
- if (exception == null) return String.Empty;
- string stack = String.Empty;
- if (includeStackTrace && exception.StackTrace != null)
- stack = String.Format(Environment.NewLine + exception.StackTrace);
-
- string message = exception.Message;
-
- return string.Format(Environment.NewLine + "Exc level {0}: {1}: {2}{3}",
- level,
- exception.GetType(),
- message,
- stack);
- }
- }
-}
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator.MSBuild/Orleans.CodeGenerator.MSBuild.csproj b/src/Orleans.CodeGenerator.MSBuild/Orleans.CodeGenerator.MSBuild.csproj
index dc1ba01b7f1..1d0d42c25e3 100644
--- a/src/Orleans.CodeGenerator.MSBuild/Orleans.CodeGenerator.MSBuild.csproj
+++ b/src/Orleans.CodeGenerator.MSBuild/Orleans.CodeGenerator.MSBuild.csproj
@@ -7,7 +7,7 @@
- netcoreapp2.0
+ net462
Exe
true
tasks
diff --git a/src/Orleans.CodeGenerator.MSBuild/Program.cs b/src/Orleans.CodeGenerator.MSBuild/Program.cs
index 4f6fe49136a..2e049e45746 100644
--- a/src/Orleans.CodeGenerator.MSBuild/Program.cs
+++ b/src/Orleans.CodeGenerator.MSBuild/Program.cs
@@ -57,6 +57,8 @@ private static int SourceToSource(string[] args)
if (!File.Exists(argsFile)) throw new ArgumentException($"Arguments file \"{argsFile}\" does not exist.");
var fileArgs = File.ReadAllLines(argsFile);
+ char[] charSeparators = new char[] { ',' };
+
foreach (var arg in fileArgs)
{
var parts = arg.Split(new[] {':'}, 2);
@@ -100,7 +102,7 @@ private static int SourceToSource(string[] args)
cmd.Reference.Add(value);
break;
case nameof(cmd.DefineConstants):
- cmd.DefineConstants.AddRange(value.Split(',', StringSplitOptions.RemoveEmptyEntries));
+ cmd.DefineConstants.AddRange(value.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries));
break;
case nameof(cmd.CodeGenOutputFile):
cmd.CodeGenOutputFile = value;
diff --git a/src/Orleans.CodeGenerator.MSBuild/build/Microsoft.Orleans.CodeGenerator.MSBuild.targets b/src/Orleans.CodeGenerator.MSBuild/build/Microsoft.Orleans.CodeGenerator.MSBuild.targets
index 707b8f49cf9..3a75fdcb606 100644
--- a/src/Orleans.CodeGenerator.MSBuild/build/Microsoft.Orleans.CodeGenerator.MSBuild.targets
+++ b/src/Orleans.CodeGenerator.MSBuild/build/Microsoft.Orleans.CodeGenerator.MSBuild.targets
@@ -12,7 +12,7 @@
Orleans_CodeGeneratorTargetFramework;">
- netcoreapp2.0
+ net462
dotnet
$(OrleansCodeGenCoreAssembly)
$(MSBuildThisFileDirectory)..\tasks\$(Orleans_CodeGeneratorTargetFramework)\Orleans.CodeGenerator.MSBuild.dll
diff --git a/src/Orleans.CodeGenerator.MSBuild/buildMultiTargeting/Microsoft.Orleans.CodeGenerator.MSBuild.targets b/src/Orleans.CodeGenerator.MSBuild/buildMultiTargeting/Microsoft.Orleans.CodeGenerator.MSBuild.targets
deleted file mode 100644
index 5cd5f0facf8..00000000000
--- a/src/Orleans.CodeGenerator.MSBuild/buildMultiTargeting/Microsoft.Orleans.CodeGenerator.MSBuild.targets
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator/Analysis/CompilationAnalyzer.cs b/src/Orleans.CodeGenerator/Analysis/CompilationAnalyzer.cs
deleted file mode 100644
index 18ee9d4aa1e..00000000000
--- a/src/Orleans.CodeGenerator/Analysis/CompilationAnalyzer.cs
+++ /dev/null
@@ -1,318 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.Extensions.Logging;
-using Orleans.CodeGenerator.Compatibility;
-using Orleans.CodeGenerator.Utilities;
-
-namespace Orleans.CodeGenerator.Analysis
-{
- internal class CompilationAnalyzer
- {
- private readonly ILogger log;
- private readonly WellKnownTypes wellKnownTypes;
- private readonly INamedTypeSymbol serializableAttribute;
- private readonly INamedTypeSymbol knownBaseTypeAttribute;
- private readonly INamedTypeSymbol knownAssemblyAttribute;
- private readonly INamedTypeSymbol considerForCodeGenerationAttribute;
-
- ///
- /// Assemblies whose declared types are all considered serializable.
- ///
- private readonly HashSet assembliesWithForcedSerializability = new HashSet();
-
- ///
- /// Types whose sub-types are all considered serializable.
- ///
- private readonly HashSet knownBaseTypes = new HashSet();
-
- ///
- /// Types which were observed in a grain interface.
- ///
- private readonly HashSet dependencyTypes = new HashSet();
-
- private readonly HashSet grainInterfacesToProcess = new HashSet();
- private readonly HashSet grainClassesToProcess = new HashSet();
- private readonly HashSet serializationTypesToProcess = new HashSet();
- private readonly HashSet fieldOfSerializableType = new HashSet();
-
- public CompilationAnalyzer(ILogger log, WellKnownTypes wellKnownTypes)
- {
- this.log = log;
- this.wellKnownTypes = wellKnownTypes;
- this.serializableAttribute = wellKnownTypes.SerializableAttribute;
- this.knownBaseTypeAttribute = wellKnownTypes.KnownBaseTypeAttribute;
- this.knownAssemblyAttribute = wellKnownTypes.KnownAssemblyAttribute;
- this.considerForCodeGenerationAttribute = wellKnownTypes.ConsiderForCodeGenerationAttribute;
- }
-
- public HashSet CodeGenerationRequiredTypes { get; } = new HashSet();
- public HashSet KnownAssemblies { get; } = new HashSet();
- public HashSet KnownTypes { get; } = new HashSet();
-
- public (IEnumerable grainClasses, IEnumerable grainInterfaces, IEnumerable types) GetTypesToProcess() =>
- (this.grainClassesToProcess, this.grainInterfacesToProcess, this.GetSerializationTypesToProcess());
-
- private IEnumerable GetSerializationTypesToProcess()
- {
- var done = new HashSet();
- var remaining = new HashSet();
- while (done.Count != this.serializationTypesToProcess.Count)
- {
- remaining.Clear();
- foreach (var type in this.serializationTypesToProcess)
- {
- if (done.Add(type)) remaining.Add(type);
- }
-
- foreach (var type in remaining)
- {
- yield return type;
- }
- }
- }
-
- public bool IsSerializable(INamedTypeSymbol type)
- {
- var result = false;
- if (type.IsSerializable || type.HasAttribute(this.serializableAttribute))
- {
- if (log.IsEnabled(LogLevel.Debug)) log.LogDebug($"Type {type} has [Serializable] attribute");
- result = true;
- }
-
- if (!result && this.assembliesWithForcedSerializability.Contains(type.ContainingAssembly))
- {
- if (log.IsEnabled(LogLevel.Debug)) log.LogDebug($"Type {type} is declared in an assembly in which all types are considered serializable");
- result = true;
- }
-
- if (!result && this.KnownTypes.Contains(type))
- {
- if (log.IsEnabled(LogLevel.Debug)) log.LogDebug($"Type {type} is a known type");
- result = true;
- }
-
- if (!result && this.dependencyTypes.Contains(type))
- {
- if (log.IsEnabled(LogLevel.Debug)) log.LogDebug($"Type {type} was discovered on a grain method signature or in another serializable type");
- result = true;
- }
-
- if (!result)
- {
- for (var current = type; current != null; current = current.BaseType)
- {
- if (!knownBaseTypes.Contains(current)) continue;
-
- if (log.IsEnabled(LogLevel.Debug)) log.LogDebug($"Type {type} has a known base type");
- result = true;
- }
- }
-
- if (!result)
- {
- foreach (var iface in type.AllInterfaces)
- {
- if (!knownBaseTypes.Contains(iface)) continue;
-
- if (log.IsEnabled(LogLevel.Debug)) log.LogDebug($"Type {type} has a known base interface");
- result = true;
- }
- }
-
- if (!result && this.fieldOfSerializableType.Contains(type))
- {
- if (log.IsEnabled(LogLevel.Debug)) log.LogDebug($"Type {type} is used in a field of another serializable type");
- result = true;
- }
-
- if (!result)
- {
- if (log.IsEnabled(LogLevel.Trace)) log.LogTrace($"Type {type} is not serializable");
- }
- else
- {
- foreach (var field in type.GetAllMembers())
- {
- ExpandGenericArguments(field.Type);
- }
-
- void ExpandGenericArguments(ITypeSymbol typeSymbol)
- {
- if (typeSymbol is INamedTypeSymbol named && this.fieldOfSerializableType.Add(named))
- {
- InspectType(named);
- foreach (var param in named.GetHierarchyTypeArguments())
- {
- ExpandGenericArguments(param);
- }
- }
- }
- }
-
- return result;
- }
-
- public bool IsFromKnownAssembly(ITypeSymbol type) => this.KnownAssemblies.Contains(type.OriginalDefinition.ContainingAssembly);
-
- private void InspectGrainInterface(INamedTypeSymbol type)
- {
- this.serializationTypesToProcess.Add(type);
- this.grainInterfacesToProcess.Add(type);
- foreach (var method in type.GetAllMembers())
- {
- if (method.ReturnType is INamedTypeSymbol returnType)
- {
- foreach (var named in ExpandType(returnType).OfType())
- {
- this.AddDependencyType(named);
- this.serializationTypesToProcess.Add(named);
- }
- }
-
- foreach (var param in method.Parameters)
- {
- if (param.Type is INamedTypeSymbol parameterType)
- {
- foreach (var named in ExpandType(parameterType).OfType())
- {
- this.AddDependencyType(named);
- this.serializationTypesToProcess.Add(named);
- }
- }
- }
- }
- }
-
- private static IEnumerable ExpandType(ITypeSymbol symbol)
- {
- yield return symbol;
- switch (symbol)
- {
- case IArrayTypeSymbol array:
- foreach (var t in ExpandType(array.ElementType)) yield return t;
- break;
- case INamedTypeSymbol named:
- foreach (var p in named.TypeArguments)
- foreach (var t in ExpandType(p))
- yield return t;
- break;
- }
-
- if (symbol.BaseType != null)
- {
- foreach (var t in ExpandType(symbol.BaseType)) yield return t;
- }
- }
-
- public void InspectType(INamedTypeSymbol type)
- {
- if (type.HasAttribute(knownBaseTypeAttribute)) this.AddKnownBaseType(type);
- if (this.wellKnownTypes.IsGrainInterface(type)) this.InspectGrainInterface(type);
- if (this.wellKnownTypes.IsGrainClass(type)) this.grainClassesToProcess.Add(type);
- this.serializationTypesToProcess.Add(type);
- }
-
- public void InspectAssembly(IAssemblySymbol assembly)
- {
- // Recursively all assemblies considered known from the inspected assembly.
- ExpandKnownAssemblies(assembly);
-
- // Add all types considered known from each known assembly.
- ExpandKnownTypes(this.KnownAssemblies);
-
- void ExpandKnownAssemblies(IAssemblySymbol asm)
- {
- if (!this.KnownAssemblies.Add(asm))
- {
- return;
- }
-
- if (!asm.GetAttributes(this.knownAssemblyAttribute, out var attrs)) return;
-
- foreach (var attr in attrs)
- {
- var param = attr.ConstructorArguments.First();
- if (param.Kind != TypedConstantKind.Type)
- {
- throw new ArgumentException($"Unrecognized argument type in attribute [{attr.AttributeClass.Name}({param.ToCSharpString()})]");
- }
-
- var type = (ITypeSymbol)param.Value;
- if (log.IsEnabled(LogLevel.Debug)) log.LogDebug($"Known assembly {type.ContainingAssembly} from assembly {asm}");
-
- // Check if the attribute has the TreatTypesAsSerializable property set.
- var prop = attr.NamedArguments.Where(a => a.Key.Equals("TreatTypesAsSerializable")).Select(a => a.Value).FirstOrDefault();
- if (prop.Type != null)
- {
- var treatAsSerializable = (bool)prop.Value;
- if (treatAsSerializable)
- {
- // When checking if a type in this assembly is serializable, always respond that it is.
- this.AddAssemblyWithForcedSerializability(asm);
- }
- }
-
- // Recurse on the assemblies which the type was declared in.
- ExpandKnownAssemblies(type.OriginalDefinition.ContainingAssembly);
- }
- }
-
- void ExpandKnownTypes(IEnumerable asm)
- {
- foreach (var a in asm)
- {
- if (!a.GetAttributes(this.considerForCodeGenerationAttribute, out var attrs)) continue;
-
- foreach (var attr in attrs)
- {
- var typeParam = attr.ConstructorArguments.First();
- if (typeParam.Kind != TypedConstantKind.Type)
- {
- throw new ArgumentException($"Unrecognized argument type in attribute [{attr.AttributeClass.Name}({typeParam.ToCSharpString()})]");
- }
-
- var type = (INamedTypeSymbol)typeParam.Value;
- this.KnownTypes.Add(type);
-
- var throwOnFailure = false;
- var throwOnFailureParam = attr.ConstructorArguments.Skip(1).FirstOrDefault();
- if (throwOnFailureParam.Type != null)
- {
- throwOnFailure = (bool)throwOnFailureParam.Value;
- if (throwOnFailure) this.CodeGenerationRequiredTypes.Add(type);
- }
-
- if (log.IsEnabled(LogLevel.Debug)) log.LogDebug($"Known type {type}, Throw on failure: {throwOnFailure}");
- }
- }
- }
- }
-
- public void AddAssemblyWithForcedSerializability(IAssemblySymbol asm) => this.assembliesWithForcedSerializability.Add(asm);
-
- public void AddKnownBaseType(INamedTypeSymbol type)
- {
- if (log.IsEnabled(LogLevel.Debug)) this.log.LogDebug($"Added known base type {type}");
- this.knownBaseTypes.Add(type);
- }
-
- public void AddDependencyType(ITypeSymbol type)
- {
- if (!(type is INamedTypeSymbol named)) return;
- if (named.IsGenericType && !named.IsUnboundGenericType)
- {
- var unbound = named.ConstructUnboundGenericType();
- if (unbound.Equals(this.wellKnownTypes.Task_1))
- {
- return;
- }
- }
-
- this.dependencyTypes.Add(type);
- }
- }
-}
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator/Analysis/SerializerTypeAnalyzer.cs b/src/Orleans.CodeGenerator/Analysis/SerializerTypeAnalyzer.cs
deleted file mode 100644
index 049309497b5..00000000000
--- a/src/Orleans.CodeGenerator/Analysis/SerializerTypeAnalyzer.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis;
-using Orleans.CodeGenerator.Utilities;
-
-namespace Orleans.CodeGenerator.Analysis
-{
- internal class SerializerTypeAnalyzer
- {
- private readonly INamedTypeSymbol copierMethodAttribute;
- private readonly INamedTypeSymbol serializerMethodAttribute;
- private readonly INamedTypeSymbol deserializerMethodAttribute;
- private readonly INamedTypeSymbol serializerAttribute;
-
- public SerializerTypeAnalyzer(
- INamedTypeSymbol copierMethodAttribute,
- INamedTypeSymbol serializerMethodAttribute,
- INamedTypeSymbol deserializerMethodAttribute,
- INamedTypeSymbol serializerAttribute)
- {
- this.copierMethodAttribute = copierMethodAttribute;
- this.serializerMethodAttribute = serializerMethodAttribute;
- this.deserializerMethodAttribute = deserializerMethodAttribute;
- this.serializerAttribute = serializerAttribute;
- }
-
- public static SerializerTypeAnalyzer Create(WellKnownTypes wellKnownTypes) => new SerializerTypeAnalyzer(
- wellKnownTypes.CopierMethodAttribute,
- wellKnownTypes.SerializerMethodAttribute,
- wellKnownTypes.DeserializerMethodAttribute,
- wellKnownTypes.SerializerAttribute);
-
- public bool IsSerializer(INamedTypeSymbol type, out INamedTypeSymbol[] targetTypes)
- {
- if (!HasSerializerMethods(type))
- {
- targetTypes = Array.Empty();
- return false;
- }
-
- if (type.GetAttributes(this.serializerAttribute, out var attrs))
- {
- var targets = attrs.Select(attr => (INamedTypeSymbol)attr.ConstructorArguments.First().Value);
- targetTypes = targets.ToArray();
- }
- else
- {
- // This is only a self-serializing type.
- // Self-serializing types do not require the [Serializer(typeof(X))] attribute.
- targetTypes = new[] { type };
- }
-
- return true;
- }
-
- private bool HasSerializerMethods(ITypeSymbol type)
- {
- var (hasCopier, hasSerializer, hasDeserializer) = (false, false, false);
- foreach (var member in type.GetMembers())
- {
- if (!(member is IMethodSymbol method)) continue;
- if (method.HasAttribute(this.copierMethodAttribute)) hasCopier = true;
- else if (method.HasAttribute(this.serializerMethodAttribute)) hasSerializer = true;
- else if (method.HasAttribute(this.deserializerMethodAttribute)) hasDeserializer = true;
-
- if (hasCopier && hasSerializer && hasDeserializer) return true;
- }
-
- return false;
- }
- }
-}
diff --git a/src/Orleans.CodeGenerator/CodeGenerationException.cs b/src/Orleans.CodeGenerator/CodeGenerationException.cs
deleted file mode 100644
index e22fb56cd99..00000000000
--- a/src/Orleans.CodeGenerator/CodeGenerationException.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System;
-using System.Runtime.Serialization;
-
-namespace Orleans.CodeGenerator
-{
- ///
- /// Signifies an error that occurred during code generation.
- ///
- [Serializable]
- public class CodeGenerationException : Exception
- {
- public CodeGenerationException()
- {
- }
-
- public CodeGenerationException(string message)
- : base(message)
- {
- }
-
- public CodeGenerationException(string message, Exception innerException)
- : base(message, innerException)
- {
- }
-
- protected CodeGenerationException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- }
- }
-}
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator/CodeGenerator.cs b/src/Orleans.CodeGenerator/CodeGenerator.cs
deleted file mode 100644
index 2e3b1d02d56..00000000000
--- a/src/Orleans.CodeGenerator/CodeGenerator.cs
+++ /dev/null
@@ -1,449 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.Extensions.Logging;
-using Orleans.CodeGenerator.Analysis;
-using Orleans.CodeGenerator.Compatibility;
-using Orleans.CodeGenerator.Generators;
-using Orleans.CodeGenerator.Model;
-using Orleans.CodeGenerator.Utilities;
-using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-
-namespace Orleans.CodeGenerator
-{
- public class CodeGenerator
- {
- public const string ToolName = "OrleansCodeGen";
- public static readonly string Version = typeof(CodeGenerator).Assembly.GetName().Version.ToString();
-
- private readonly Compilation compilation;
- private readonly ILogger log;
- private readonly WellKnownTypes wellKnownTypes;
- private readonly SemanticModel semanticModelForAccessibility;
- private readonly CompilationAnalyzer compilationAnalyzer;
- private readonly SerializerTypeAnalyzer serializerTypeAnalyzer;
-
- public CodeGenerator(Compilation compilation, ILogger log)
- {
- this.compilation = compilation;
- this.log = log;
- this.wellKnownTypes = WellKnownTypes.FromCompilation(compilation);
- this.compilationAnalyzer = new CompilationAnalyzer(log, this.wellKnownTypes);
-
- var firstSyntaxTree = compilation.SyntaxTrees.FirstOrDefault() ?? throw new InvalidOperationException("Compilation has no syntax trees.");
- this.semanticModelForAccessibility = compilation.GetSemanticModel(firstSyntaxTree);
- this.serializerTypeAnalyzer = SerializerTypeAnalyzer.Create(this.wellKnownTypes);
- }
-
- public CompilationUnitSyntax GenerateCode(CancellationToken cancellationToken)
- {
- // Create a model of the code to generate from the collection of types.
- var model = this.AnalyzeCompilation();
-
- // Perform some validation against the generated model.
- this.ValidateModel(model);
-
- // Finally, generate code for the model.
- return this.GenerateSyntax(model);
- }
-
- private AggregatedModel AnalyzeCompilation()
- {
- // Inspect the target assembly to discover known assemblies and known types.
- if (log.IsEnabled(LogLevel.Debug)) log.LogDebug($"Main assembly {this.compilation.Assembly}");
- this.compilationAnalyzer.InspectAssembly(this.compilation.Assembly);
-
- // Create a list of all distinct types from all known assemblies.
- var types = this.compilationAnalyzer
- .KnownAssemblies.SelectMany(a => a.GetDeclaredTypes())
- .Concat(this.compilationAnalyzer.KnownTypes)
- .Distinct()
- .ToList();
-
- var model = new AggregatedModel();
-
- // Inspect all types
- foreach (var type in types) this.compilationAnalyzer.InspectType(type);
-
- // Get the types which need processing.
- var (grainClasses, grainInterfaces, serializationTypes) = this.compilationAnalyzer.GetTypesToProcess();
-
- // Process each of the types into the model.
- foreach (var grainInterface in grainInterfaces) this.ProcessGrainInterface(model, grainInterface);
- foreach (var grainClass in grainClasses)
- {
- this.ProcessGrainClass(model, grainClass);
- this.ProcessSerializableType(model, grainClass);
- }
-
- foreach (var type in serializationTypes) this.ProcessSerializableType(model, type);
-
- var otherAssemblies = this.compilation.References
- .Select(a => this.compilation.GetAssemblyOrModuleSymbol(a))
- .OfType()
- .Where(a => !this.compilationAnalyzer.KnownAssemblies.Contains(a));
- foreach (var type in otherAssemblies.SelectMany(a => a.GetDeclaredTypes()))
- {
- if (this.ValidForKnownTypes(type)) AddKnownType(model, type);
- }
-
- return model;
- }
-
- private void ValidateModel(AggregatedModel model)
- {
- // Check that all types which the developer marked as requiring code generation have had code generation.
- foreach (var required in this.compilationAnalyzer.CodeGenerationRequiredTypes)
- {
- if (!model.Serializers.SerializerTypes.Any(t => t.Target.Equals(required)))
- {
- throw new CodeGenerationException(
- $"Found {this.wellKnownTypes.ConsiderForCodeGenerationAttribute} with ThrowOnFailure set for type {required}, but a serializer" +
- " could not be generated. Ensure that the type is accessible.");
- }
- }
- }
-
- private CompilationUnitSyntax GenerateSyntax(AggregatedModel model)
- {
- var namespaceGroupings = new Dictionary>();
-
- // Pass the relevent elements of the model to each of the code generators.
- foreach (var grainInterface in model.GrainInterfaces)
- {
- var nsMembers = GetNamespace(namespaceGroupings, grainInterface.Type.ContainingNamespace);
- nsMembers.Add(GrainMethodInvokerGenerator.GenerateClass(this.wellKnownTypes, grainInterface));
- nsMembers.Add(GrainReferenceGenerator.GenerateClass(this.wellKnownTypes, grainInterface));
- }
-
- var serializersToGenerate = model.Serializers.SerializerTypes
- .Where(s => s.SerializerTypeSyntax == null)
- .Distinct(SerializerTypeDescription.TargetComparer);
- foreach (var serializerType in serializersToGenerate)
- {
- var nsMembers = GetNamespace(namespaceGroupings, serializerType.Target.ContainingNamespace);
- TypeDeclarationSyntax generated;
- (generated, serializerType.SerializerTypeSyntax) = SerializerGenerator.GenerateClass(this.wellKnownTypes, this.semanticModelForAccessibility, serializerType);
- nsMembers.Add(generated);
- }
-
- var compilationMembers = new List();
-
- // Group the generated code by namespace since serialized types, such as the generated GrainReference classes must have a stable namespace.
- foreach (var group in namespaceGroupings)
- {
- var ns = group.Key;
- var members = group.Value;
- if (ns.IsGlobalNamespace)
- {
- compilationMembers.AddRange(members);
- }
- else
- {
- compilationMembers.Add(NamespaceDeclaration(ParseName(ns.ToDisplayString())).AddMembers(members.ToArray()));
- }
- }
-
- // Add and generate feature populators to tie everything together.
- var (attributes, featurePopulators) = FeaturePopulatorGenerator.GenerateSyntax(this.wellKnownTypes, model);
- compilationMembers.AddRange(featurePopulators);
-
- return CompilationUnit()
- .AddUsings(UsingDirective(ParseName("global::Orleans")))
- .WithAttributeLists(List(attributes))
- .WithMembers(List(compilationMembers));
-
- List GetNamespace(Dictionary> namespaces, INamespaceSymbol ns)
- {
- if (namespaces.TryGetValue(ns, out var result)) return result;
- return namespaces[ns] = new List();
- }
- }
-
- private void ProcessGrainInterface(AggregatedModel model, INamedTypeSymbol type)
- {
- var accessible = this.semanticModelForAccessibility.IsAccessible(0, type);
-
- if (this.log.IsEnabled(LogLevel.Debug))
- {
- this.log.LogDebug($"Found grain interface: {type.ToDisplayString()} {(accessible ? "accessible" : "NOT accessible")}");
- }
-
- if (accessible)
- {
- var genericMethod = type.GetAllMembers().FirstOrDefault(m => m.IsGenericMethod);
- if (genericMethod != null && this.wellKnownTypes.GenericMethodInvoker is WellKnownTypes.None)
- {
- if (this.log.IsEnabled(LogLevel.Warning))
- {
- var message = $"Grain interface {type} has a generic method, {genericMethod}." +
- " Support for generic methods requires the project to reference Microsoft.Orleans.Core, but this project does not reference it.";
- this.log.LogError(message);
- throw new CodeGenerationException(message);
- }
- }
-
- var methods = GetGrainMethodDescriptions(type);
-
- model.GrainInterfaces.Add(new GrainInterfaceDescription(
- type,
- this.wellKnownTypes.GetTypeId(type),
- this.wellKnownTypes.GetVersion(type),
- methods));
- }
-
- // Returns a list of all methods in all interfaces on the provided type.
- IEnumerable GetGrainMethodDescriptions(INamedTypeSymbol initialType)
- {
- IEnumerable GetAllInterfaces(INamedTypeSymbol s)
- {
- if (s.TypeKind == TypeKind.Interface)
- yield return s;
- foreach (var i in s.AllInterfaces) yield return i;
- }
-
- foreach (var iface in GetAllInterfaces(initialType))
- {
- foreach (var member in iface.GetMembers())
- {
- if (!(member is IMethodSymbol method)) continue;
- yield return new GrainMethodDescription(this.wellKnownTypes.GetMethodId(method), method);
- }
- }
- }
- }
-
- private void ProcessGrainClass(AggregatedModel model, INamedTypeSymbol type)
- {
- var accessible = this.semanticModelForAccessibility.IsAccessible(0, type);
-
- if (this.log.IsEnabled(LogLevel.Debug))
- {
- this.log.LogDebug($"Found grain class: {type.ToDisplayString()} {(accessible ? "accessible" : "NOT accessible")}");
- }
-
- if (accessible)
- {
- model.GrainClasses.Add(new GrainClassDescription(type, this.wellKnownTypes.GetTypeId(type)));
- }
- }
-
- private void ProcessSerializableType(AggregatedModel model, INamedTypeSymbol type)
- {
- if (!ValidForKnownTypes(type))
- {
- if (this.log.IsEnabled(LogLevel.Trace)) this.log.LogTrace($"{nameof(ProcessSerializableType)} skipping abstract type {type}");
- return;
- }
-
- AddKnownType(model, type);
-
- var serializerModel = model.Serializers;
-
- if (type.IsAbstract)
- {
- if (this.log.IsEnabled(LogLevel.Trace)) this.log.LogTrace($"{nameof(ProcessSerializableType)} skipping abstract type {type}");
- return;
- }
-
- // Ensure that the type is accessible from generated code.
- var accessible = this.semanticModelForAccessibility.IsAccessible(0, type);
- if (!accessible)
- {
- if (this.log.IsEnabled(LogLevel.Trace)) this.log.LogTrace($"{nameof(ProcessSerializableType)} skipping inaccessible type {type}");
- return;
- }
-
- if (type.HasBaseType(this.wellKnownTypes.Exception))
- {
- if (this.log.IsEnabled(LogLevel.Trace)) this.log.LogTrace($"{nameof(ProcessSerializableType)} skipping Exception type {type}");
- return;
- }
-
- if (type.HasBaseType(this.wellKnownTypes.Delegate))
- {
- if (this.log.IsEnabled(LogLevel.Trace)) this.log.LogTrace($"{nameof(ProcessSerializableType)} skipping Delegate type {type}");
- return;
- }
-
- if (type.AllInterfaces.Contains(this.wellKnownTypes.IAddressable))
- {
- if (this.log.IsEnabled(LogLevel.Trace)) this.log.LogTrace($"{nameof(ProcessSerializableType)} skipping IAddressable type {type}");
- return;
- }
-
- // Account for types that serialize themselves and/or are serializers for other types.
- var selfSerializing = false;
- if (this.serializerTypeAnalyzer.IsSerializer(type, out var serializerTargets))
- {
- var typeSyntax = type.ToTypeSyntax();
- foreach (var target in serializerTargets)
- {
- if (this.log.IsEnabled(LogLevel.Trace))
- {
- this.log.LogTrace($"{nameof(ProcessSerializableType)} type {type} is a serializer for {target}");
- }
-
- if (target.Equals(type))
- {
- selfSerializing = true;
- typeSyntax = type.WithoutTypeParameters().ToTypeSyntax();
- }
-
- serializerModel.SerializerTypes.Add(new SerializerTypeDescription
- {
- Target = target,
- SerializerTypeSyntax = typeSyntax,
- OverrideExistingSerializer = true
- });
- }
- }
-
- if (selfSerializing)
- {
- if (this.log.IsEnabled(LogLevel.Trace)) this.log.LogTrace($"{nameof(ProcessSerializableType)} skipping serializer generation for self-serializing type {type}");
- return;
- }
-
- if (type.HasAttribute(this.wellKnownTypes.GeneratedCodeAttribute))
- {
- if (this.log.IsEnabled(LogLevel.Trace))
- {
- this.log.LogTrace($"{nameof(ProcessSerializableType)} type {type} is a generated type and no serializer will be generated for it");
- }
-
- return;
- }
-
- if (type.IsStatic)
- {
- if (this.log.IsEnabled(LogLevel.Trace))
- {
- this.log.LogTrace($"{nameof(ProcessSerializableType)} type {type} is a static type and no serializer will be generated for it");
- }
-
- return;
- }
-
- if (type.TypeParameters.Any(p => p.ConstraintTypes.Any(c => c.Equals(this.wellKnownTypes.Delegate))))
- {
- if (this.log.IsEnabled(LogLevel.Trace)) this.log.LogTrace($"{nameof(ProcessSerializableType)} skipping type with Delegate parameter constraint, {type}");
- return;
- }
-
- var isSerializable = this.compilationAnalyzer.IsSerializable(type);
- if (this.compilationAnalyzer.IsFromKnownAssembly(type) && isSerializable)
- {
- // Skip types which have fields whose types are inaccessible from generated code.
- foreach (var field in type.GetAllMembers())
- {
- // Ignore fields which won't be serialized anyway.
- if (!SerializerGenerator.ShouldSerializeField(this.wellKnownTypes, field))
- {
- if (this.log.IsEnabled(LogLevel.Trace))
- {
- this.log.LogTrace($"{nameof(ProcessSerializableType)} skipping non-serialized field {field} in type {type}");
- }
-
- continue;
- }
-
- // Check field type accessibility.
- var fieldAccessible = this.semanticModelForAccessibility.IsAccessible(0, field.Type);
- if (!fieldAccessible)
- {
- if (this.log.IsEnabled(LogLevel.Trace))
- {
- this.log.LogTrace($"{nameof(ProcessSerializableType)} skipping type {type} with inaccessible field type {field.Type} (field: {field})");
- }
-
- return;
- }
- }
-
- // Add the type that needs generation.
- // The serializer generator will fill in the missing SerializerTypeSyntax field with the
- // generated type.
- if (this.log.IsEnabled(LogLevel.Trace))
- {
- this.log.LogTrace($"{nameof(ProcessSerializableType)} will generate a serializer for type {type}");
- }
-
- serializerModel.SerializerTypes.Add(new SerializerTypeDescription
- {
- Target = type
- });
- }
- else if (this.log.IsEnabled(LogLevel.Trace))
- {
- this.log.LogTrace($"{nameof(ProcessSerializableType)} will not generate a serializer for type {type}");
- }
- }
-
- private static void AddKnownType(AggregatedModel model, INamedTypeSymbol type)
- {
- // Many types which will never have a serializer generated are still added to known types so that they can be used to identify the type
- // in a serialized payload. For example, when serializing List, SomeAbstractType must be known. The same applies to
- // interfaces (which are encoded as abstract).
- var serializerModel = model.Serializers;
- serializerModel.KnownTypes.Add(new KnownTypeDescription
- {
- Type = type.WithoutTypeParameters(),
- TypeKey = type.OrleansTypeKeyString()
- });
- }
-
- private bool ValidForKnownTypes(INamedTypeSymbol type)
- {
- // Skip implicitly declared types like anonymous classes and closures.
- if (type.IsImplicitlyDeclared)
- {
- //if (this.log.IsEnabled(LogLevel.Trace)) this.log.LogTrace($"{nameof(ValidForKnownTypes)} skipping implicitly declared type {type}");
- return false;
- }
-
- if (!type.CanBeReferencedByName)
- {
- //if (this.log.IsEnabled(LogLevel.Trace)) this.log.LogTrace($"{nameof(ValidForKnownTypes)} skipping type which cannot be referenced by name {type}");
- return false;
- }
-
- if (type.HasUnsupportedMetadata)
- {
- //if (this.log.IsEnabled(LogLevel.Trace)) this.log.LogTrace($"{nameof(ValidForKnownTypes)} skipping type with unsupported metadata {type}");
- return false;
- }
-
- if (type.SpecialType != SpecialType.None)
- {
- //if (this.log.IsEnabled(LogLevel.Trace)) this.log.LogTrace($"{nameof(ValidForKnownTypes)} skipping special type {type}");
-
- return false;
- }
-
- switch (type.TypeKind)
- {
- case TypeKind.Unknown:
- case TypeKind.Array:
- case TypeKind.Delegate:
- case TypeKind.Dynamic:
- case TypeKind.Error:
- case TypeKind.Module:
- case TypeKind.Pointer:
- case TypeKind.TypeParameter:
- case TypeKind.Submission:
- {
- if (this.log.IsEnabled(LogLevel.Trace)) this.log.LogTrace($"{nameof(ValidForKnownTypes)} skipping type {type} of kind {type.TypeKind}");
- return false;
- }
- }
-
- if (this.log.IsEnabled(LogLevel.Trace)) this.log.LogTrace($"{nameof(ValidForKnownTypes)} adding type {type}");
-
- return true;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator/Compatibility/OrleansLegacyCompat.cs b/src/Orleans.CodeGenerator/Compatibility/OrleansLegacyCompat.cs
deleted file mode 100644
index 1f03bcb0b37..00000000000
--- a/src/Orleans.CodeGenerator/Compatibility/OrleansLegacyCompat.cs
+++ /dev/null
@@ -1,390 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Linq;
-using System.Security.Cryptography;
-using System.Text;
-using Microsoft.CodeAnalysis;
-using Orleans.CodeGenerator.Utilities;
-
-namespace Orleans.CodeGenerator.Compatibility
-{
- internal static class OrleansLegacyCompat
- {
- public static int GetMethodId(this WellKnownTypes wellKnownTypes, IMethodSymbol methodInfo)
- {
- if (GetAttribute(methodInfo, wellKnownTypes.MethodIdAttribute) is AttributeData attr)
- {
- return (int)attr.ConstructorArguments.First().Value;
- }
-
- var result = FormatMethodForMethodIdComputation(methodInfo);
- return CalculateIdHash(result);
- }
-
- internal static string FormatMethodForMethodIdComputation(IMethodSymbol methodInfo)
- {
- var result = new StringBuilder(methodInfo.Name);
-
- if (methodInfo.IsGenericMethod)
- {
- result.Append('<');
- var first = true;
- foreach (var arg in methodInfo.TypeArguments)
- {
- if (!first) result.Append(',');
- else first = false;
- result.Append(RoslynTypeNameFormatter.Format(arg, RoslynTypeNameFormatter.Style.RuntimeTypeNameFormatter));
- }
-
- result.Append('>');
- }
-
- {
- result.Append('(');
- var parameters = methodInfo.Parameters;
- var first = true;
- foreach (var parameter in parameters)
- {
- if (!first)
- result.Append(',');
- var parameterType = parameter.Type;
- switch (parameterType)
- {
- case ITypeParameterSymbol _:
- result.Append(parameterType.Name);
- break;
- default:
- result.Append(RoslynTypeNameFormatter.Format(parameterType, RoslynTypeNameFormatter.Style.RuntimeTypeNameFormatter));
- break;
- }
-
- first = false;
- }
- }
-
- result.Append(')');
- return result.ToString();
- }
-
- public static int GetTypeId(this WellKnownTypes wellKnownTypes, INamedTypeSymbol type)
- {
- if (GetAttribute(type, wellKnownTypes.TypeCodeOverrideAttribute) is AttributeData attr)
- {
- return (int)attr.ConstructorArguments.First().Value;
- }
-
- var fullName = FormatTypeForIdComputation(type);
- return CalculateIdHash(fullName);
- }
-
- private static AttributeData GetAttribute(ISymbol type, ITypeSymbol attributeType)
- {
- var attrs = type.GetAttributes();
- foreach (var attr in attrs)
- {
- if (attr.AttributeClass.Equals(attributeType))
- {
- return attr;
- }
- }
-
- return null;
- }
-
- private static int CalculateIdHash(string text)
- {
- var sha = SHA256.Create();
- var hash = 0;
- try
- {
- var data = Encoding.Unicode.GetBytes(text);
- var result = sha.ComputeHash(data);
- for (var i = 0; i < result.Length; i += 4)
- {
- var tmp = (result[i] << 24) | (result[i + 1] << 16) | (result[i + 2] << 8) | result[i + 3];
- hash = hash ^ tmp;
- }
- }
- finally
- {
- sha.Dispose();
- }
-
- return hash;
- }
-
- internal static string FormatTypeForIdComputation(INamedTypeSymbol symbol) =>
- GetTemplatedName(
- GetFullName(symbol),
- symbol,
- symbol.TypeArguments,
- t => false);
-
- public static ushort GetVersion(this WellKnownTypes wellKnownTypes, ISymbol symbol)
- {
- if (GetAttribute(symbol, wellKnownTypes.VersionAttribute) is AttributeData attr)
- {
- return (ushort)attr.ConstructorArguments.First().Value;
- }
-
- // Return the default version
- return 0;
- }
-
- ///
- /// Returns true if the provided type is a grain interface.
- ///
- public static bool IsGrainInterface(this WellKnownTypes types, INamedTypeSymbol type)
- {
- if (type.TypeKind != TypeKind.Interface) return false;
-
- var orig = type.OriginalDefinition;
- return orig.AllInterfaces.Contains(types.IAddressable) && !IsGrainMarkerInterface(types, orig);
-
- bool IsGrainMarkerInterface(WellKnownTypes l, INamedTypeSymbol t)
- {
- return Equals(t, l.IGrainObserver) ||
- Equals(t, l.IAddressable) ||
- Equals(t, l.IGrainExtension) ||
- Equals(t, l.IGrain) ||
- Equals(t, l.IGrainWithGuidKey) ||
- Equals(t, l.IGrainWithIntegerKey) ||
- Equals(t, l.IGrainWithStringKey) ||
- Equals(t, l.IGrainWithGuidCompoundKey) ||
- Equals(t, l.IGrainWithIntegerCompoundKey) ||
- Equals(t, l.ISystemTarget);
- }
- }
-
- ///
- /// Returns true if the provided type is a grain implementation.
- ///
- public static bool IsGrainClass(this WellKnownTypes types, INamedTypeSymbol type)
- {
- if (type.TypeKind != TypeKind.Class) return false;
-
- var orig = type.OriginalDefinition;
- return HasBase(orig, types.Grain) && !IsMarkerType(types, orig);
-
- bool IsMarkerType(WellKnownTypes l, INamedTypeSymbol t)
- {
- return Equals(t, l.Grain) || Equals(t, l.GrainOfT);
- }
-
- bool HasBase(INamedTypeSymbol t, INamedTypeSymbol baseType)
- {
- if (Equals(t.BaseType, baseType)) return true;
- if (t.BaseType != null) return HasBase(t.BaseType, baseType);
- return false;
- }
- }
- public static string OrleansTypeKeyString(this ITypeSymbol t)
- {
- var sb = new StringBuilder();
-
- var namedType = t as INamedTypeSymbol;
-
- // Check if the type is a non-constructed generic type.
- if (namedType != null && namedType.IsGenericType && namedType.ConstructedFrom.Equals(t))
- {
- sb.Append(GetBaseTypeKey(t));
- sb.Append('\'');
- sb.Append(namedType.TypeParameters.Length);
- }
- else if (namedType != null && namedType.IsGenericType)
- {
- sb.Append(GetBaseTypeKey(t));
- sb.Append('<');
- var first = true;
- foreach (var genericArgument in namedType.TypeArguments)
- {
- if (!first)
- {
- sb.Append(',');
- }
- first = false;
- sb.Append(OrleansTypeKeyString(genericArgument));
- }
-
- sb.Append('>');
- }
- else if (t is IArrayTypeSymbol arrayType)
- {
- sb.Append(OrleansTypeKeyString(arrayType.ElementType));
-
- sb.Append('[');
- if (arrayType.Rank > 1)
- {
- sb.Append(',', arrayType.Rank - 1);
- }
- sb.Append(']');
- }
- else
- {
- sb.Append(GetBaseTypeKey(t));
- }
-
- return sb.ToString();
- }
-
- private static string GetBaseTypeKey(ITypeSymbol type)
- {
- var namespacePrefix = "";
- var ns = type.ContainingNamespace?.ToString();
- if (ns != null && !ns.StartsWith("System.") && !ns.Equals("System"))
- {
- namespacePrefix = ns + '.';
- }
-
- if (type.DeclaredAccessibility == Accessibility.Public && type.ContainingType != null)
- {
- return namespacePrefix + OrleansTypeKeyString(type.ContainingType) + "." + type.Name;
- }
-
- return namespacePrefix + type.Name;
- }
-
- public static string GetTemplatedName(ITypeSymbol type, Func fullName = null)
- {
- if (fullName == null) fullName = _ => true;
-
- switch (type)
- {
- case IArrayTypeSymbol array:
- return GetTemplatedName(array.ElementType, fullName)
- + "["
- + new string(',', array.Rank - 1)
- + "]";
- case INamedTypeSymbol named when named.IsGenericType:
- return GetTemplatedName(GetSimpleTypeName(named, fullName), named, named.TypeArguments, fullName);
- case INamedTypeSymbol named:
- return GetSimpleTypeName(named, fullName);
- case ITypeParameterSymbol parameter:
- return parameter.Name;
- default:
- throw new NotSupportedException($"Symbol {type} of type {type.GetType()} is not supported.");
- }
- }
-
- public static string GetTemplatedName(string baseName, INamedTypeSymbol type, ImmutableArray genericArguments, Func fullName)
- {
- if (!type.IsGenericType || type.ContainingType != null && type.ContainingType.IsGenericType) return baseName;
- var s = baseName;
- s += "<";
- s += GetGenericTypeArgs(genericArguments, fullName);
- s += ">";
- return s;
- }
-
- public static string GetGenericTypeArgs(IEnumerable args, Func fullName)
- {
- var result = string.Empty;
-
- var first = true;
- foreach (var genericParameter in args)
- {
- if (!first)
- {
- result += ",";
- }
-
- if (genericParameter is INamedTypeSymbol named && !named.IsGenericType)
- {
- result += GetSimpleTypeName(named, fullName);
- }
- else
- {
- result += GetTemplatedName(genericParameter, fullName);
- }
-
- first = false;
- }
-
- return result;
- }
-
- public static string GetSimpleTypeName(ITypeSymbol type, Func fullName = null)
- {
- var named = type as INamedTypeSymbol;
- if (type.ContainingType != null)
- {
- if (type.ContainingType.IsGenericType)
- {
- return GetTemplatedName(
- GetUntemplatedTypeName(type.ContainingType.Name),
- type.ContainingType,
- named?.TypeArguments ?? default(ImmutableArray),
- _ => true) + "." + GetUntemplatedTypeName(type.Name);
- }
-
- return GetTemplatedName(type.ContainingType) + "." + GetUntemplatedTypeName(type.Name);
- }
-
- if (named == null || named.IsGenericType) return GetSimpleTypeName(fullName != null && fullName(type) ? GetFullName(type) : type.Name);
-
- return fullName != null && fullName(type) ? GetFullName(type) : type.Name;
- }
-
- public static string GetUntemplatedTypeName(string typeName)
- {
- var i = typeName.IndexOf('`');
- if (i > 0)
- {
- typeName = typeName.Substring(0, i);
- }
- i = typeName.IndexOf('<');
- if (i > 0)
- {
- typeName = typeName.Substring(0, i);
- }
- return typeName;
- }
-
- public static string GetSimpleTypeName(string typeName)
- {
- var i = typeName.IndexOf('`');
- if (i > 0)
- {
- typeName = typeName.Substring(0, i);
- }
- i = typeName.IndexOf('[');
- if (i > 0)
- {
- typeName = typeName.Substring(0, i);
- }
- i = typeName.IndexOf('<');
- if (i > 0)
- {
- typeName = typeName.Substring(0, i);
- }
- return typeName;
- }
-
- public static string GetFullName(ITypeSymbol t)
- {
- if (t == null) throw new ArgumentNullException(nameof(t));
- if (t.ContainingType != null && !(t is ITypeParameterSymbol))
- {
- return $"{t.GetNamespaceName()}.{t.ContainingType.Name}.{t.Name}{GetArity(t)}";
- }
-
- if (t is IArrayTypeSymbol array)
- {
- return GetFullName(array.ElementType)
- + "["
- + new string(',', array.Rank - 1)
- + "]";
- }
-
- return RoslynTypeNameFormatter.Format(t, RoslynTypeNameFormatter.Style.FullName); // ?? (t is ITypeParameterSymbol) ? t.Name : t.GetNamespaceName() + "." + t.Name;
-
- string GetArity(ITypeSymbol type)
- {
- if (!(type is INamedTypeSymbol named)) return string.Empty;
- if (named.TypeArguments.Length > 0) return $"`{named.TypeArguments.Length}";
- return string.Empty;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator/Compatibility/RoslynTypeNameFormatter.cs b/src/Orleans.CodeGenerator/Compatibility/RoslynTypeNameFormatter.cs
deleted file mode 100644
index 23acf243366..00000000000
--- a/src/Orleans.CodeGenerator/Compatibility/RoslynTypeNameFormatter.cs
+++ /dev/null
@@ -1,215 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.CodeAnalysis;
-using Orleans.CodeGenerator.Utilities;
-
-namespace Orleans.CodeGenerator.Compatibility
-{
- ///
- /// Utility methods for formatting instances in a way which can be later parsed by .
- ///
- internal static class RoslynTypeNameFormatter
- {
- private static readonly char[] SimpleNameTerminators = { '`', '*', '[', '&' };
-
- public enum Style
- {
- FullName,
- RuntimeTypeNameFormatter
- }
-
- ///
- /// Returns a form of which can be parsed by .
- ///
- public static string Format(ITypeSymbol type, Style style)
- {
- if (type == null) throw new ArgumentNullException(nameof(type));
-
- var builder = new StringBuilder();
- Format(builder, type, isElementType: false, style: style, depth: 0);
- return builder.ToString();
- }
-
- private static void Format(StringBuilder builder, ITypeSymbol type, bool isElementType, Style style, int depth)
- {
- switch (type)
- {
- case IPointerTypeSymbol pointer:
- Format(builder, pointer.PointedAtType, isElementType: true, style: style, depth: depth + 1);
- AddPointerSymbol(builder);
- break;
- case IArrayTypeSymbol array:
- Format(builder, array.ElementType, isElementType: true, style: style, depth: depth + 1);
- AddArrayRank(builder, array);
- break;
- case INamedTypeSymbol named:
- AddNamespace(builder, type);
- AddClassName(builder, named);
- AddGenericParameters(builder, named, style, depth + 1);
- break;
- case ITypeParameterSymbol parameter:
- if (style != Style.FullName)
- {
- AddNamespace(builder, type);
- AddClassName(builder, parameter);
- }
-
- break;
- default:
- throw new NotSupportedException($"Type symbol {type} of type {type.GetType()} (interfaces: {string.Join(", ", type.AllInterfaces.Select(i => i.ToString()))}) is not supported");
- }
-
- // Types which are used as elements are not formatted with their assembly name, since that is added after the
- // element type's adornments.
- if (!isElementType)
- {
- switch (style)
- {
- case Style.FullName:
- if (depth != 0) AddAssembly(builder, type, style);
- break;
- case Style.RuntimeTypeNameFormatter:
- AddAssembly(builder, type, style);
- break;
- default:
- throw new ArgumentOutOfRangeException(nameof(style), style, null);
- }
- }
- }
-
- private static void AddNamespace(StringBuilder builder, ITypeSymbol type)
- {
- var namespaceName = type.GetNamespaceName();
- if (string.IsNullOrWhiteSpace(namespaceName)) return;
- builder.Append(namespaceName);
- builder.Append('.');
- }
-
- private static void AddClassName(StringBuilder builder, INamedTypeSymbol type)
- {
- // Format the declaring type.
- if (type.ContainingType != null)
- {
- AddClassName(builder, type.ContainingType);
- builder.Append('+');
- }
-
- // Format the simple type name.
- var index = type.Name.IndexOfAny(SimpleNameTerminators);
- builder.Append(index > 0 ? type.Name.Substring(0, index) : type.Name);
-
- // Format this type's generic arity.
- AddGenericArity(builder, type);
- }
-
- private static void AddClassName(StringBuilder builder, ITypeParameterSymbol type)
- {
- // Format the declaring type.
- if (type.ContainingType != null)
- {
- AddClassName(builder, type.ContainingType);
- builder.Append('+');
- }
-
- // Format the simple type name.
- var index = type.Name.IndexOfAny(SimpleNameTerminators);
- builder.Append(index > 0 ? type.Name.Substring(0, index) : type.Name);
- }
-
- private static List GetHierarchyTypeArguments(ITypeSymbol type)
- {
- return Helper(type).ToList();
-
- IEnumerable Helper(ITypeSymbol t)
- {
- if (t.ContainingType != null)
- {
- foreach (var arg in Helper(t.ContainingType)) yield return arg;
- }
-
- if (t is INamedTypeSymbol named)
- foreach (var arg in named.TypeArguments)
- yield return arg;
- }
- }
-
-
- private static void AddGenericParameters(StringBuilder builder, INamedTypeSymbol type, Style style, int depth)
- {
- // Generic type definitions (eg, List<> without parameters) and non-generic types do not include any
- // parameters in their formatting.
- if (type.IsUnboundGenericType) return;
-
- var args = GetHierarchyTypeArguments(type);
- if (args.Count == 0) return;
- if (args.All(a => a is ITypeParameterSymbol)) return;
-
- builder.Append('[');
- for (var i = 0; i < args.Count; i++)
- {
- builder.Append('[');
- Format(builder, args[i], isElementType: false, style: style, depth: depth);
- builder.Append(']');
- if (i + 1 < args.Count) builder.Append(",");
- }
-
- builder.Append(']');
- }
-
- private static void AddGenericArity(StringBuilder builder, INamedTypeSymbol type)
- {
- if (!type.IsGenericType) return;
-
- if (type.TypeArguments.Length == 0) return;
-
- builder.Append('`');
- builder.Append(type.TypeArguments.Length);
- }
-
- private static void AddPointerSymbol(StringBuilder builder)
- {
- builder.Append('*');
- }
-
- private static void AddArrayRank(StringBuilder builder, IArrayTypeSymbol type)
- {
- builder.Append('[');
- builder.Append(',', type.Rank - 1);
- builder.Append(']');
- }
-
- private static void AddAssembly(StringBuilder builder, ITypeSymbol type, Style style)
- {
- switch (type)
- {
- case IPointerTypeSymbol p:
- AddAssembly(builder, p.PointedAtType, style);
- break;
- case IArrayTypeSymbol a:
- AddAssembly(builder, a.ElementType, style);
- break;
- default:
- var assembly = type.ContainingAssembly;
- if (assembly == null) return;
-
- switch (style)
- {
- case Style.FullName:
- builder.Append(", ");
- builder.Append(assembly.Identity.GetDisplayName());
- break;
- case Style.RuntimeTypeNameFormatter:
- var isSystemAssembly = type.ContainingAssembly.GetTypeByMetadataName("System.Int32") != null;
- if (isSystemAssembly) return;
- builder.Append(",");
- builder.Append(assembly.Identity.Name);
- break;
- }
-
- break;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator/Directory.Build.props b/src/Orleans.CodeGenerator/Directory.Build.props
deleted file mode 100644
index 3cc5f4166c9..00000000000
--- a/src/Orleans.CodeGenerator/Directory.Build.props
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
- <_ParentDirectoryBuildPropsPath Condition="'$(_DirectoryBuildPropsFile)' != ''">$([System.IO.Path]::Combine('..', '$(_DirectoryBuildPropsFile)'))
-
-
-
-
-
- false
-
-
-
- true
-
-
-
-
- true
- https://github.com/dotnet/orleans
-
-
-
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator/Generators/FeaturePopulatorGenerator.cs b/src/Orleans.CodeGenerator/Generators/FeaturePopulatorGenerator.cs
deleted file mode 100644
index 26933628d6a..00000000000
--- a/src/Orleans.CodeGenerator/Generators/FeaturePopulatorGenerator.cs
+++ /dev/null
@@ -1,130 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Orleans.CodeGenerator.Compatibility;
-using Orleans.CodeGenerator.Model;
-using Orleans.CodeGenerator.Utilities;
-using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-
-namespace Orleans.CodeGenerator.Generators
-{
- internal static class FeaturePopulatorGenerator
- {
- internal const string NamespaceName = "OrleansGeneratedCode";
- private const string ClassSuffix = "FeaturePopulator";
-
- public static (List, List) GenerateSyntax(WellKnownTypes wellKnownTypes, AggregatedModel model)
- {
- var attributes = new List();
- var members = new List();
- var className = CodeGenerator.ToolName + Guid.NewGuid().ToString("N").Substring(0, 10) + ClassSuffix;
-
- // Generate a class for populating the metadata.
- var classSyntax = ClassDeclaration(className)
- .AddBaseListTypes(
- SimpleBaseType(wellKnownTypes.IFeaturePopulator_1.Construct(wellKnownTypes.GrainInterfaceFeature).ToTypeSyntax()),
- SimpleBaseType(wellKnownTypes.IFeaturePopulator_1.Construct(wellKnownTypes.GrainClassFeature).ToTypeSyntax()),
- SimpleBaseType(wellKnownTypes.IFeaturePopulator_1.Construct(wellKnownTypes.SerializerFeature).ToTypeSyntax()))
- .AddModifiers(Token(SyntaxKind.InternalKeyword), Token(SyntaxKind.SealedKeyword))
- .AddMembers(
- GeneratePopulateMethod(wellKnownTypes, model.GrainInterfaces),
- GeneratePopulateMethod(wellKnownTypes, model.GrainClasses),
- GeneratePopulateMethod(wellKnownTypes, model.Serializers))
- .AddAttributeLists(AttributeList(SingletonSeparatedList(GeneratedCodeAttributeGenerator.GetGeneratedCodeAttributeSyntax(wellKnownTypes))));
-
- var namespaceSyntax = NamespaceDeclaration(NamespaceName.ToIdentifierName()).AddMembers(classSyntax);
- members.Add(namespaceSyntax);
-
- // Generate an assembly-level attribute with an instance of that class.
- var attribute = AttributeList(
- AttributeTargetSpecifier(Token(SyntaxKind.AssemblyKeyword)),
- SingletonSeparatedList(
- Attribute(wellKnownTypes.FeaturePopulatorAttribute.ToNameSyntax())
- .AddArgumentListArguments(AttributeArgument(TypeOfExpression(ParseTypeName(NamespaceName + "." + className))))));
- attributes.Add(attribute);
-
- return (attributes, members);
- }
-
- private static MemberDeclarationSyntax GeneratePopulateMethod(WellKnownTypes wellKnownTypes, List grains)
- {
- var interfaceMethod = wellKnownTypes.IFeaturePopulator_1.Construct(wellKnownTypes.GrainInterfaceFeature).Method("Populate");
- var featureParameter = interfaceMethod.Parameters.First().Name.ToIdentifierName();
-
- var bodyStatements = new List();
- foreach (var metadata in grains)
- {
- var newMetadataExpression = ObjectCreationExpression(wellKnownTypes.GrainInterfaceMetadata.ToTypeSyntax())
- .AddArgumentListArguments(
- Argument(TypeOfExpression(metadata.Type.WithoutTypeParameters().ToTypeSyntax())),
- Argument(TypeOfExpression(metadata.ReferenceType)),
- Argument(TypeOfExpression(metadata.InvokerType)),
- Argument(metadata.InterfaceId.ToHexLiteral()));
- bodyStatements.Add(
- ExpressionStatement(
- InvocationExpression(featureParameter.Member("Interfaces").Member("Add"))
- .AddArgumentListArguments(
- Argument(newMetadataExpression))));
- }
-
- return interfaceMethod.GetDeclarationSyntax().AddBodyStatements(bodyStatements.ToArray());
- }
-
- private static MemberDeclarationSyntax GeneratePopulateMethod(WellKnownTypes wellKnownTypes, List grains)
- {
- var interfaceMethod = wellKnownTypes.IFeaturePopulator_1.Construct(wellKnownTypes.GrainClassFeature).Method("Populate");
- var featureParameter = interfaceMethod.Parameters.First().Name.ToIdentifierName();
-
- var bodyStatements = new List();
- foreach (var metadata in grains)
- {
- var newMetadataExpression = ObjectCreationExpression(wellKnownTypes.GrainClassMetadata.ToTypeSyntax())
- .AddArgumentListArguments(
- Argument(TypeOfExpression(metadata.Type.WithoutTypeParameters().ToTypeSyntax())));
- bodyStatements.Add(
- ExpressionStatement(
- InvocationExpression(featureParameter.Member("Classes").Member("Add"))
- .AddArgumentListArguments(
- Argument(newMetadataExpression))));
- }
-
- return interfaceMethod.GetDeclarationSyntax().AddBodyStatements(bodyStatements.ToArray());
- }
-
- private static MemberDeclarationSyntax GeneratePopulateMethod(WellKnownTypes wellKnownTypes, SerializationTypeDescriptions typeDescriptions)
- {
- var interfaceMethod = wellKnownTypes.IFeaturePopulator_1.Construct(wellKnownTypes.SerializerFeature).Method("Populate");
- var featureParameter = interfaceMethod.Parameters.First().Name.ToIdentifierName();
-
- var bodyStatements = new List();
-
- foreach (var serializerType in typeDescriptions.SerializerTypes)
- {
- if (serializerType.SerializerTypeSyntax == null) continue;
- var overrideExisting = serializerType.OverrideExistingSerializer ? SyntaxKind.TrueLiteralExpression : SyntaxKind.FalseLiteralExpression;
- bodyStatements.Add(
- ExpressionStatement(
- InvocationExpression(featureParameter.Member("AddSerializerType"))
- .AddArgumentListArguments(
- Argument(TypeOfExpression(serializerType.Target.WithoutTypeParameters().ToTypeSyntax())),
- Argument(TypeOfExpression(serializerType.SerializerTypeSyntax)),
- Argument(LiteralExpression(overrideExisting)))));
- }
-
- foreach (var knownType in typeDescriptions.KnownTypes)
- {
- bodyStatements.Add(
- ExpressionStatement(
- InvocationExpression(featureParameter.Member("AddKnownType"))
- .AddArgumentListArguments(
- Argument(RoslynTypeNameFormatter.Format(knownType.Type, RoslynTypeNameFormatter.Style.RuntimeTypeNameFormatter).ToLiteralExpression()),
- Argument(knownType.TypeKey.ToLiteralExpression()))));
- }
-
- return interfaceMethod.GetDeclarationSyntax().AddBodyStatements(bodyStatements.ToArray());
- }
- }
-}
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator/Generators/GeneratedCodeAttributeGenerator.cs b/src/Orleans.CodeGenerator/Generators/GeneratedCodeAttributeGenerator.cs
deleted file mode 100644
index 30c6f5d58cc..00000000000
--- a/src/Orleans.CodeGenerator/Generators/GeneratedCodeAttributeGenerator.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Orleans.CodeGenerator.Utilities;
-using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-
-namespace Orleans.CodeGenerator.Generators
-{
- internal static class GeneratedCodeAttributeGenerator
- {
- internal static AttributeSyntax GetGeneratedCodeAttributeSyntax(WellKnownTypes wellKnownTypes)
- {
- return
- Attribute(wellKnownTypes.GeneratedCodeAttribute.ToNameSyntax())
- .AddArgumentListArguments(
- AttributeArgument(CodeGenerator.ToolName.ToLiteralExpression()),
- AttributeArgument(CodeGenerator.Version.ToLiteralExpression()));
- }
- }
-}
diff --git a/src/Orleans.CodeGenerator/Generators/GrainInterfaceCommon.cs b/src/Orleans.CodeGenerator/Generators/GrainInterfaceCommon.cs
deleted file mode 100644
index 76ab06bdf5e..00000000000
--- a/src/Orleans.CodeGenerator/Generators/GrainInterfaceCommon.cs
+++ /dev/null
@@ -1,169 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Orleans.CodeGenerator.Compatibility;
-using Orleans.CodeGenerator.Model;
-using Orleans.CodeGenerator.Utilities;
-using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-
-namespace Orleans.CodeGenerator.Generators
-{
- internal static class GrainInterfaceCommon
- {
- ///
- /// Generates switch cases for the provided grain type.
- ///
- ///
- ///
- ///
- /// The method id argument, which is used to select the correct switch label.
- ///
- ///
- /// The function used to generate switch block statements for each method.
- ///
- ///
- /// The function used to compose method switch blocks for each interface.
- ///
- ///
- /// The switch cases for the provided grain type.
- ///
- public static SwitchSectionSyntax[] GenerateGrainInterfaceAndMethodSwitch(
- WellKnownTypes types,
- INamedTypeSymbol grainType,
- ExpressionSyntax methodIdArgument,
- Func generateMethodHandler,
- Func composeInterfaceBlock)
- {
- var interfaces = new List {grainType};
- interfaces.AddRange(grainType.AllInterfaces.Where(types.IsGrainInterface));
-
- // Switch on interface id.
- var interfaceCases = new List();
- foreach (var type in interfaces)
- {
- var interfaceId = types.GetTypeId(type);
- var allMethods = new[] {type}.Concat(type.AllInterfaces).SelectMany(i => i.GetMembers().OfType());
-
- var methodCases = new List();
-
- // Switch on method id.
- foreach (var method in allMethods)
- {
- // Generate switch case.
- var methodId = types.GetMethodId(method);
-
- var methodType = method;
-
- // Generate the switch label for this interface id.
- var methodIdSwitchLabel = CaseSwitchLabel(methodId.ToHexLiteral());
-
- // Generate the switch body.
- var methodInvokeStatement = generateMethodHandler(methodType);
-
- methodCases.Add(
- SwitchSection().AddLabels(methodIdSwitchLabel).AddStatements(methodInvokeStatement));
- }
-
- // Generate the switch label for this interface id.
- var interfaceIdSwitchLabel = CaseSwitchLabel(interfaceId.ToHexLiteral());
-
- // Generate switch statements for the methods in this interface.
- var methodSwitchStatements = composeInterfaceBlock(type, SwitchStatement(methodIdArgument).AddSections(methodCases.ToArray()));
-
- // Generate the switch section for this interface.
- interfaceCases.Add(
- SwitchSection().AddLabels(interfaceIdSwitchLabel).AddStatements(methodSwitchStatements));
- }
-
- return interfaceCases.ToArray();
- }
-
- public static PropertyDeclarationSyntax GenerateInterfaceIdProperty(WellKnownTypes wellKnownTypes, GrainInterfaceDescription description)
- {
- var property = wellKnownTypes.IGrainMethodInvoker.Property("InterfaceId");
- var returnValue = description.InterfaceId.ToHexLiteral();
- return
- PropertyDeclaration(wellKnownTypes.Int32.ToTypeSyntax(), property.Name)
- .WithExpressionBody(ArrowExpressionClause(returnValue))
- .AddModifiers(Token(SyntaxKind.PublicKeyword))
- .WithSemicolonToken(Token(SyntaxKind.SemicolonToken));
- }
-
- public static PropertyDeclarationSyntax GenerateInterfaceVersionProperty(WellKnownTypes wellKnownTypes, GrainInterfaceDescription description)
- {
- var property = wellKnownTypes.IGrainMethodInvoker.Property("InterfaceVersion");
- var returnValue = LiteralExpression(
- SyntaxKind.NumericLiteralExpression,
- Literal(description.InterfaceVersion));
- return
- PropertyDeclaration(wellKnownTypes.UInt16.ToTypeSyntax(), property.Name)
- .WithExpressionBody(ArrowExpressionClause(returnValue))
- .AddModifiers(Token(SyntaxKind.PublicKeyword))
- .WithSemicolonToken(Token(SyntaxKind.SemicolonToken));
- }
-
- public static LocalFunctionStatementSyntax GenerateMethodNotImplementedFunction(
- WellKnownTypes types,
- string interfaceIdVariableName = "i",
- string functionName = "ThrowInterfaceNotImplemented")
- {
- const string interfaceIdText = "InterfaceId: 0x";
- var formatAsHexadecimal = InterpolationFormatClause(Token(SyntaxKind.ColonToken), Token(TriviaList(), SyntaxKind.InterpolatedStringTextToken, "X", "X", TriviaList()));
- var errorMessage = InterpolatedStringExpression(Token(SyntaxKind.InterpolatedStringStartToken))
- .WithContents(List(new InterpolatedStringContentSyntax[]
- {
- InterpolatedStringText().WithTextToken(Token(TriviaList(), SyntaxKind.InterpolatedStringTextToken, interfaceIdText, interfaceIdText, TriviaList())),
- Interpolation(IdentifierName(interfaceIdVariableName)).WithFormatClause(formatAsHexadecimal)
- }));
- var throwExpression =
- ThrowExpression(
- ObjectCreationExpression(types.NotImplementedException.ToTypeSyntax())
- .AddArgumentListArguments(Argument(errorMessage)));
-
- var throwInterfaceNotImplemented = LocalFunctionStatement(PredefinedType(Token(SyntaxKind.VoidKeyword)), Identifier(functionName))
- .WithParameterList(ParameterList(SingletonSeparatedList(Parameter(Identifier(interfaceIdVariableName)).WithType(PredefinedType(Token(SyntaxKind.IntKeyword))))))
- .WithExpressionBody(ArrowExpressionClause(throwExpression))
- .WithSemicolonToken(Token(SyntaxKind.SemicolonToken));
- return throwInterfaceNotImplemented;
- }
-
- public static LocalFunctionStatementSyntax GenerateInterfaceNotImplementedFunction(
- WellKnownTypes types,
- string interfaceIdVariableName = "i",
- string methodIdVariableName = "m",
- string functionName = "ThrowMethodNotImplemented")
- {
- const string interfaceIdText = "InterfaceId: 0x";
- const string methodIdText = ", MethodId: 0x";
-
- var formatAsHexadecimal = InterpolationFormatClause(Token(SyntaxKind.ColonToken), Token(TriviaList(), SyntaxKind.InterpolatedStringTextToken, "X", "X", TriviaList()));
-
- var errorMessage = InterpolatedStringExpression(Token(SyntaxKind.InterpolatedStringStartToken))
- .WithContents(List(new InterpolatedStringContentSyntax[]
- {
- InterpolatedStringText().WithTextToken(Token(TriviaList(), SyntaxKind.InterpolatedStringTextToken, interfaceIdText, interfaceIdText, TriviaList())),
- Interpolation(IdentifierName(interfaceIdVariableName)).WithFormatClause(formatAsHexadecimal),
- InterpolatedStringText().WithTextToken(Token(TriviaList(), SyntaxKind.InterpolatedStringTextToken, methodIdText, methodIdText, TriviaList())),
- Interpolation(IdentifierName(methodIdVariableName)).WithFormatClause(formatAsHexadecimal),
- }));
-
- var throwExpression =
- ThrowExpression(
- ObjectCreationExpression(types.NotImplementedException.ToTypeSyntax())
- .AddArgumentListArguments(Argument(errorMessage)));
-
- var throwInterfaceNotImplemented = LocalFunctionStatement(PredefinedType(Token(SyntaxKind.VoidKeyword)), Identifier(functionName))
- .WithParameterList(ParameterList(SeparatedList(new[]
- {
- Parameter(Identifier(interfaceIdVariableName)).WithType(PredefinedType(Token(SyntaxKind.IntKeyword))),
- Parameter(Identifier(methodIdVariableName)).WithType(PredefinedType(Token(SyntaxKind.IntKeyword)))
- })))
- .WithExpressionBody(ArrowExpressionClause(throwExpression))
- .WithSemicolonToken(Token(SyntaxKind.SemicolonToken));
- return throwInterfaceNotImplemented;
- }
- }
-}
diff --git a/src/Orleans.CodeGenerator/Generators/GrainMethodInvokerGenerator.cs b/src/Orleans.CodeGenerator/Generators/GrainMethodInvokerGenerator.cs
deleted file mode 100644
index 142024bf30c..00000000000
--- a/src/Orleans.CodeGenerator/Generators/GrainMethodInvokerGenerator.cs
+++ /dev/null
@@ -1,314 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Orleans.CodeGenerator.Model;
-using Orleans.CodeGenerator.Utilities;
-using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-
-namespace Orleans.CodeGenerator.Generators
-{
- ///
- /// Generates IGrainMethodInvoker implementations for grains.
- ///
- internal static class GrainMethodInvokerGenerator
- {
- ///
- /// Returns the name of the generated class for the provided type.
- ///
- internal static string GetGeneratedClassName(INamedTypeSymbol type) => CodeGenerator.ToolName + type.GetSuitableClassName() + "MethodInvoker";
-
- ///
- /// Generates the class for the provided grain types.
- ///
- internal static TypeDeclarationSyntax GenerateClass(WellKnownTypes wellKnownTypes, GrainInterfaceDescription description)
- {
- var generatedTypeName = description.InvokerTypeName;
- var grainType = description.Type;
- var baseTypes = new List { SimpleBaseType(wellKnownTypes.IGrainMethodInvoker.ToTypeSyntax()) };
-
- var genericTypes = grainType.GetHierarchyTypeParameters()
- .Select(_ => TypeParameter(_.ToString()))
- .ToArray();
-
- // Create the special method invoker marker attribute.
- var interfaceId = description.InterfaceId;
- var interfaceIdArgument = interfaceId.ToHexLiteral();
- var grainTypeArgument = TypeOfExpression(grainType.WithoutTypeParameters().ToTypeSyntax());
- var attributes = new List
- {
- GeneratedCodeAttributeGenerator.GetGeneratedCodeAttributeSyntax(wellKnownTypes),
- Attribute(wellKnownTypes.MethodInvokerAttribute.ToNameSyntax())
- .AddArgumentListArguments(
- AttributeArgument(grainTypeArgument),
- AttributeArgument(interfaceIdArgument)),
- Attribute(wellKnownTypes.ExcludeFromCodeCoverageAttribute.ToNameSyntax())
- };
-
- var genericInvokerFields = GenerateGenericInvokerFields(wellKnownTypes, description.Methods);
- var members = new List(genericInvokerFields)
- {
- GenerateInvokeMethod(wellKnownTypes, grainType),
- GrainInterfaceCommon.GenerateInterfaceIdProperty(wellKnownTypes, description),
- GrainInterfaceCommon.GenerateInterfaceVersionProperty(wellKnownTypes, description)
- };
-
- // If this is an IGrainExtension, make the generated class implement IGrainExtensionMethodInvoker.
- if (grainType.HasInterface(wellKnownTypes.IGrainExtension))
- {
- baseTypes.Add(SimpleBaseType(wellKnownTypes.IGrainExtensionMethodInvoker.ToTypeSyntax()));
- members.Add(GenerateExtensionInvokeMethod(wellKnownTypes, grainType));
- }
-
- var classDeclaration =
- ClassDeclaration(generatedTypeName)
- .AddModifiers(Token(SyntaxKind.InternalKeyword))
- .AddBaseListTypes(baseTypes.ToArray())
- .AddConstraintClauses(grainType.GetTypeConstraintSyntax())
- .AddMembers(members.ToArray())
- .AddAttributeLists(AttributeList().AddAttributes(attributes.ToArray()));
- if (genericTypes.Length > 0)
- {
- classDeclaration = classDeclaration.AddTypeParameterListParameters(genericTypes);
- }
-
- return classDeclaration;
- }
-
- ///
- /// Generates syntax for the IGrainMethodInvoker.Invoke method.
- ///
- private static MethodDeclarationSyntax GenerateInvokeMethod(WellKnownTypes wellKnownTypes, INamedTypeSymbol grainType)
- {
- // Get the method with the correct type.
- var invokeMethod = wellKnownTypes.IGrainMethodInvoker.Method("Invoke", wellKnownTypes.IAddressable, wellKnownTypes.InvokeMethodRequest);
-
- return GenerateInvokeMethod(wellKnownTypes, grainType, invokeMethod);
- }
-
- ///
- /// Generates syntax for the IGrainExtensionMethodInvoker.Invoke method.
- ///
- private static MethodDeclarationSyntax GenerateExtensionInvokeMethod(WellKnownTypes wellKnownTypes, INamedTypeSymbol grainType)
- {
- // Get the method with the correct type.
- var invokeMethod = wellKnownTypes.IGrainExtensionMethodInvoker.Method("Invoke", wellKnownTypes.IGrainExtension, wellKnownTypes.InvokeMethodRequest);
-
- return GenerateInvokeMethod(wellKnownTypes, grainType, invokeMethod);
- }
-
- ///
- /// Generates syntax for an invoke method.
- ///
- private static MethodDeclarationSyntax GenerateInvokeMethod(WellKnownTypes wellKnownTypes, INamedTypeSymbol grainType, IMethodSymbol invokeMethod)
- {
- var parameters = invokeMethod.Parameters;
-
- var grainArgument = parameters[0].Name.ToIdentifierName();
- var requestArgument = parameters[1].Name.ToIdentifierName();
-
- var interfaceIdProperty = wellKnownTypes.InvokeMethodRequest.Property("InterfaceId");
- var methodIdProperty = wellKnownTypes.InvokeMethodRequest.Property("MethodId");
- var argumentsProperty = wellKnownTypes.InvokeMethodRequest.Property("Arguments");
-
- // Store the relevant values from the request in local variables.
- var interfaceIdDeclaration =
- LocalDeclarationStatement(
- VariableDeclaration(wellKnownTypes.Int32.ToTypeSyntax())
- .AddVariables(
- VariableDeclarator("interfaceId")
- .WithInitializer(EqualsValueClause(requestArgument.Member(interfaceIdProperty.Name)))));
- var interfaceIdVariable = IdentifierName("interfaceId");
-
- var methodIdDeclaration =
- LocalDeclarationStatement(
- VariableDeclaration(wellKnownTypes.Int32.ToTypeSyntax())
- .AddVariables(
- VariableDeclarator("methodId")
- .WithInitializer(EqualsValueClause(requestArgument.Member(methodIdProperty.Name)))));
- var methodIdVariable = IdentifierName("methodId");
-
- var argumentsDeclaration =
- LocalDeclarationStatement(
- VariableDeclaration(IdentifierName("var"))
- .AddVariables(
- VariableDeclarator("arguments")
- .WithInitializer(EqualsValueClause(requestArgument.Member(argumentsProperty.Name)))));
- var argumentsVariable = IdentifierName("arguments");
-
- var methodDeclaration = invokeMethod.GetDeclarationSyntax()
- .AddModifiers(Token(SyntaxKind.AsyncKeyword))
- .AddBodyStatements(interfaceIdDeclaration, methodIdDeclaration, argumentsDeclaration);
-
- var callThrowMethodNotImplemented = InvocationExpression(IdentifierName("ThrowMethodNotImplemented"))
- .WithArgumentList(ArgumentList(SeparatedList(new[]
- {
- Argument(interfaceIdVariable),
- Argument(methodIdVariable)
- })));
-
- // This method is used directly after its declaration to create blocks for each interface id, comprising
- // primarily of a nested switch statement for each of the methods in the given interface.
- BlockSyntax ComposeInterfaceBlock(INamedTypeSymbol interfaceType, SwitchStatementSyntax methodSwitch)
- {
- var typedGrainDeclaration = LocalDeclarationStatement(
- VariableDeclaration(IdentifierName("var"))
- .AddVariables(
- VariableDeclarator("casted")
- .WithInitializer(EqualsValueClause(ParenthesizedExpression(CastExpression(interfaceType.ToTypeSyntax(), grainArgument))))));
-
- return Block(typedGrainDeclaration,
- methodSwitch.AddSections(SwitchSection()
- .AddLabels(DefaultSwitchLabel())
- .AddStatements(
- ExpressionStatement(callThrowMethodNotImplemented),
- ReturnStatement(LiteralExpression(SyntaxKind.NullLiteralExpression)))));
- }
-
- var interfaceCases = GrainInterfaceCommon.GenerateGrainInterfaceAndMethodSwitch(
- wellKnownTypes,
- grainType,
- methodIdVariable,
- methodType => GenerateInvokeForMethod(wellKnownTypes, IdentifierName("casted"), methodType, argumentsVariable),
- ComposeInterfaceBlock);
-
- var throwInterfaceNotImplemented = GrainInterfaceCommon.GenerateMethodNotImplementedFunction(wellKnownTypes);
- var throwMethodNotImplemented = GrainInterfaceCommon.GenerateInterfaceNotImplementedFunction(wellKnownTypes);
-
- // Generate the default case, which will call the above local function to throw .
- var callThrowInterfaceNotImplemented = InvocationExpression(IdentifierName("ThrowInterfaceNotImplemented"))
- .WithArgumentList(ArgumentList(SingletonSeparatedList(Argument(interfaceIdVariable))));
- var defaultCase = SwitchSection()
- .AddLabels(DefaultSwitchLabel())
- .AddStatements(
- ExpressionStatement(callThrowInterfaceNotImplemented),
- ReturnStatement(LiteralExpression(SyntaxKind.NullLiteralExpression)));
-
- var interfaceIdSwitch =
- SwitchStatement(interfaceIdVariable).AddSections(interfaceCases.ToArray()).AddSections(defaultCase);
- return methodDeclaration.AddBodyStatements(interfaceIdSwitch, throwInterfaceNotImplemented, throwMethodNotImplemented);
- }
-
- ///
- /// Generates syntax to invoke a method on a grain.
- ///
- private static StatementSyntax[] GenerateInvokeForMethod(
- WellKnownTypes wellKnownTypes,
- ExpressionSyntax castGrain,
- IMethodSymbol method,
- ExpressionSyntax arguments)
- {
- // Construct expressions to retrieve each of the method's parameters.
- var parameters = new List();
- var methodParameters = method.Parameters.ToList();
- for (var i = 0; i < methodParameters.Count; i++)
- {
- var parameter = methodParameters[i];
- var parameterType = parameter.Type.ToTypeSyntax();
- var indexArg = Argument(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(i)));
- var arg = CastExpression(
- parameterType,
- ElementAccessExpression(arguments).AddArgumentListArguments(indexArg));
- parameters.Add(arg);
- }
-
- // If the method is a generic method definition, use the generic method invoker field to invoke the method.
- if (method.IsGenericMethod)
- {
- var invokerFieldName = GetGenericMethodInvokerFieldName(method);
- var invokerCall = InvocationExpression(
- IdentifierName(invokerFieldName)
- .Member(wellKnownTypes.IGrainMethodInvoker.Method("Invoke").Name))
- .AddArgumentListArguments(Argument(castGrain), Argument(arguments));
- return new StatementSyntax[] { ReturnStatement(AwaitExpression(invokerCall)) };
- }
-
- // Invoke the method.
- var grainMethodCall =
- InvocationExpression(castGrain.Member(method.Name))
- .AddArgumentListArguments(parameters.Select(Argument).ToArray());
-
- // For void methods, invoke the method and return null.
- if (method.ReturnsVoid)
- {
- return new StatementSyntax[]
- {
- ExpressionStatement(grainMethodCall),
- ReturnStatement(LiteralExpression(SyntaxKind.NullLiteralExpression))
- };
- }
-
- // For methods which return an awaitable type which has no result type, await the method and return null.
- if (method.ReturnType.Method("GetAwaiter").ReturnType.Method("GetResult").ReturnsVoid)
- {
- return new StatementSyntax[]
- {
- ExpressionStatement(AwaitExpression(grainMethodCall)),
- ReturnStatement(LiteralExpression(SyntaxKind.NullLiteralExpression))
- };
- }
-
- return new StatementSyntax[]
- {
- ReturnStatement(AwaitExpression(grainMethodCall))
- };
- }
-
- ///
- /// Generates GenericMethodInvoker fields for the generic methods in .
- ///
- private static MemberDeclarationSyntax[] GenerateGenericInvokerFields(WellKnownTypes wellKnownTypes, List methodDescriptions)
- {
- if (!(wellKnownTypes.GenericMethodInvoker is WellKnownTypes.Some genericMethodInvoker)) return Array.Empty();
-
- var result = new List(methodDescriptions.Count);
- foreach (var description in methodDescriptions)
- {
- var method = description.Method;
- if (!method.IsGenericMethod) continue;
- result.Add(GenerateGenericInvokerField(method, genericMethodInvoker.Value));
- }
-
- return result.ToArray();
- }
-
- ///
- /// Generates a GenericMethodInvoker field for the provided generic method.
- ///
- private static MemberDeclarationSyntax GenerateGenericInvokerField(IMethodSymbol method, INamedTypeSymbol genericMethodInvoker)
- {
- var fieldInfoVariable =
- VariableDeclarator(GetGenericMethodInvokerFieldName(method))
- .WithInitializer(
- EqualsValueClause(
- ObjectCreationExpression(genericMethodInvoker.ToTypeSyntax())
- .AddArgumentListArguments(
- Argument(TypeOfExpression(method.ContainingType.ToTypeSyntax())),
- Argument(method.Name.ToLiteralExpression()),
- Argument(
- LiteralExpression(
- SyntaxKind.NumericLiteralExpression,
- Literal(method.TypeArguments.Length))))));
-
- return
- FieldDeclaration(
- VariableDeclaration(genericMethodInvoker.ToTypeSyntax()).AddVariables(fieldInfoVariable))
- .AddModifiers(
- Token(SyntaxKind.PrivateKeyword),
- Token(SyntaxKind.StaticKeyword),
- Token(SyntaxKind.ReadOnlyKeyword));
- }
-
- ///
- /// Returns the name of the GenericMethodInvoker field corresponding to .
- ///
- /// The method.
- /// The name of the invoker field corresponding to the provided method.
- private static string GetGenericMethodInvokerFieldName(IMethodSymbol method)
- {
- return method.Name + string.Join("_", method.TypeArguments.Select(arg => arg.Name));
- }
- }
-}
diff --git a/src/Orleans.CodeGenerator/Generators/GrainReferenceGenerator.cs b/src/Orleans.CodeGenerator/Generators/GrainReferenceGenerator.cs
deleted file mode 100644
index 231dcddeb1c..00000000000
--- a/src/Orleans.CodeGenerator/Generators/GrainReferenceGenerator.cs
+++ /dev/null
@@ -1,435 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Orleans.CodeGenerator.Compatibility;
-using Orleans.CodeGenerator.Model;
-using Orleans.CodeGenerator.Utilities;
-using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-
-namespace Orleans.CodeGenerator.Generators
-{
- ///
- /// Generates GrainReference implementations for grains.
- ///
- internal static class GrainReferenceGenerator
- {
- ///
- /// Returns the name of the generated class for the provided type.
- ///
- internal static string GetGeneratedClassName(INamedTypeSymbol type)
- {
- return CodeGenerator.ToolName + type.GetSuitableClassName() + "Reference";
- }
-
- ///
- /// Generates the class for the provided grain types.
- ///
- internal static TypeDeclarationSyntax GenerateClass(WellKnownTypes wellKnownTypes, GrainInterfaceDescription description)
- {
- var generatedTypeName = description.ReferenceTypeName;
- var grainType = description.Type;
- var genericTypes = grainType.GetHierarchyTypeParameters()
- .Select(_ => TypeParameter(_.ToString()))
- .ToArray();
-
- // Create the special marker attribute.
- var grainTypeArgument = TypeOfExpression(grainType.WithoutTypeParameters().ToTypeSyntax());
-
- var attributes = AttributeList()
- .AddAttributes(
- GeneratedCodeAttributeGenerator.GetGeneratedCodeAttributeSyntax(wellKnownTypes),
- Attribute(wellKnownTypes.SerializableAttribute.ToNameSyntax()),
- Attribute(wellKnownTypes.ExcludeFromCodeCoverageAttribute.ToNameSyntax()),
- Attribute(wellKnownTypes.GrainReferenceAttribute.ToNameSyntax())
- .AddArgumentListArguments(AttributeArgument(grainTypeArgument)));
-
- var classDeclaration =
- ClassDeclaration(generatedTypeName)
- .AddModifiers(Token(SyntaxKind.InternalKeyword))
- .AddBaseListTypes(
- SimpleBaseType(wellKnownTypes.GrainReference.ToTypeSyntax()),
- SimpleBaseType(grainType.ToTypeSyntax()))
- .AddConstraintClauses(grainType.GetTypeConstraintSyntax())
- .AddMembers(GenerateConstructors(wellKnownTypes, generatedTypeName))
- .AddMembers(
- GrainInterfaceCommon.GenerateInterfaceIdProperty(wellKnownTypes, description).AddModifiers(Token(SyntaxKind.OverrideKeyword)),
- GrainInterfaceCommon.GenerateInterfaceVersionProperty(wellKnownTypes, description).AddModifiers(Token(SyntaxKind.OverrideKeyword)),
- GenerateInterfaceNameProperty(wellKnownTypes, description),
- GenerateIsCompatibleMethod(wellKnownTypes, description),
- GenerateGetMethodNameMethod(wellKnownTypes, description))
- .AddMembers(GenerateInvokeMethods(wellKnownTypes, description))
- .AddAttributeLists(attributes);
- if (genericTypes.Length > 0)
- {
- classDeclaration = classDeclaration.AddTypeParameterListParameters(genericTypes);
- }
-
- return classDeclaration;
- }
-
- ///
- /// Generates constructors.
- ///
- private static MemberDeclarationSyntax[] GenerateConstructors(WellKnownTypes wellKnownTypes, string className)
- {
- var baseConstructors =
- wellKnownTypes.GrainReference.Constructors.Where(c => c.DeclaredAccessibility != Accessibility.Private);
- var constructors = new List();
- foreach (var baseConstructor in baseConstructors)
- {
- var args = baseConstructor.Parameters
- .Select(arg => Argument(arg.Name.ToIdentifierName()))
- .ToArray();
- var declaration =
- baseConstructor.GetConstructorDeclarationSyntax(className)
- .WithInitializer(
- ConstructorInitializer(SyntaxKind.BaseConstructorInitializer)
- .AddArgumentListArguments(args))
- .AddBodyStatements();
- constructors.Add(declaration);
- }
-
- return constructors.ToArray();
- }
-
- ///
- /// Generates invoker methods.
- ///
- private static MemberDeclarationSyntax[] GenerateInvokeMethods(WellKnownTypes wellKnownTypes, GrainInterfaceDescription description)
- {
- var baseReference = BaseExpression();
- var methods = description.Methods;
- var members = new List();
- foreach (var methodDescription in methods)
- {
- var method = methodDescription.Method;
- var methodIdArgument = Argument(methodDescription.MethodId.ToHexLiteral());
-
- // Construct a new object array from all method arguments.
- var parameters = method.Parameters;
- var body = new List();
- foreach (var parameter in parameters)
- {
- if (parameter.Type.HasInterface(wellKnownTypes.IGrainObserver))
- {
- body.Add(
- ExpressionStatement(
- InvocationExpression(wellKnownTypes.GrainFactoryBase.ToDisplayString().ToIdentifierName().Member("CheckGrainObserverParamInternal"))
- .AddArgumentListArguments(Argument(parameter.Name.ToIdentifierName()))));
- }
- }
-
- // Get the parameters argument value.
- var objectArrayType = wellKnownTypes.Object.ToTypeSyntax().GetArrayTypeSyntax();
- ExpressionSyntax args;
- if (method.IsGenericMethod)
- {
- // Create an arguments array which includes the method's type parameters followed by the method's parameter list.
- var allParameters = new List();
- foreach (var typeParameter in method.TypeParameters)
- {
- allParameters.Add(TypeOfExpression(typeParameter.ToTypeSyntax()));
- }
-
- allParameters.AddRange(parameters.Select(GetParameterForInvocation));
-
- args =
- ArrayCreationExpression(objectArrayType)
- .WithInitializer(
- InitializerExpression(SyntaxKind.ArrayInitializerExpression)
- .AddExpressions(allParameters.ToArray()));
- }
- else if (parameters.Length == 0)
- {
- args = LiteralExpression(SyntaxKind.NullLiteralExpression);
- }
- else
- {
- args =
- ArrayCreationExpression(objectArrayType)
- .WithInitializer(
- InitializerExpression(SyntaxKind.ArrayInitializerExpression)
- .AddExpressions(parameters.Select(GetParameterForInvocation).ToArray()));
- }
-
- var options = GetInvokeOptions(wellKnownTypes, method);
-
- // Construct the invocation call.
- bool asyncMethod;
- var isOneWayTask = method.HasAttribute(wellKnownTypes.OneWayAttribute);
- if (method.ReturnsVoid || isOneWayTask)
- {
- // One-way methods are never marked async.
- asyncMethod = false;
-
- var invocation = InvocationExpression(baseReference.Member("InvokeOneWayMethod"))
- .AddArgumentListArguments(methodIdArgument)
- .AddArgumentListArguments(Argument(args));
-
- if (options != null)
- {
- invocation = invocation.AddArgumentListArguments(options);
- }
-
- body.Add(ExpressionStatement(invocation));
-
- if (isOneWayTask)
- {
- if (!wellKnownTypes.Task.Equals(method.ReturnType))
- {
- throw new CodeGenerationException(
- $"Method {method} is marked with [{wellKnownTypes.OneWayAttribute.Name}], " +
- $"but has a return type which is not assignable from {typeof(Task)}");
- }
-
- var done = wellKnownTypes.Task.ToNameSyntax().Member((object _) => Task.CompletedTask);
- body.Add(ReturnStatement(done));
- }
- }
- else if (method.ReturnType is INamedTypeSymbol methodReturnType)
- {
- // If the method doesn't return a Task type (eg, it returns ValueTask), then we must make an async method and await the invocation result.
- var isTaskMethod = wellKnownTypes.Task.Equals(methodReturnType)
- || methodReturnType.IsGenericType && wellKnownTypes.Task_1.Equals(methodReturnType.ConstructedFrom);
- asyncMethod = !isTaskMethod;
-
- var returnType = methodReturnType.IsGenericType
- ? methodReturnType.TypeArguments[0]
- : wellKnownTypes.Object;
- var invokeMethodAsync = "InvokeMethodAsync".ToGenericName().AddTypeArgumentListArguments(returnType.ToTypeSyntax());
- var invocation =
- InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
- baseReference,
- invokeMethodAsync))
- .AddArgumentListArguments(methodIdArgument)
- .AddArgumentListArguments(Argument(args));
-
- if (options != null)
- {
- invocation = invocation.AddArgumentListArguments(options);
- }
-
- var methodResult = asyncMethod ? AwaitExpression(invocation) : (ExpressionSyntax)invocation;
- body.Add(ReturnStatement(methodResult));
- }
- else throw new NotSupportedException($"Method {method} has unsupported return type, {method.ReturnType}.");
-
- var methodDeclaration = method.GetDeclarationSyntax()
- .WithModifiers(TokenList())
- .WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(method.ContainingType.ToNameSyntax()))
- .AddBodyStatements(body.ToArray())
- // Since explicit implementation is used, constraints must not be specified.
- .WithConstraintClauses(new SyntaxList());
-
- if (asyncMethod) methodDeclaration = methodDeclaration.AddModifiers(Token(SyntaxKind.AsyncKeyword));
-
- members.Add(methodDeclaration);
- }
-
- return members.ToArray();
-
- ExpressionSyntax GetParameterForInvocation(IParameterSymbol arg, int argIndex)
- {
- var argIdentifier = GetParameterName(arg, argIndex).ToIdentifierName();
-
- // Addressable arguments must be converted to references before passing.
- if (arg.Type.HasInterface(wellKnownTypes.IAddressable)
- && arg.Type.TypeKind == TypeKind.Interface)
- {
- return
- ConditionalExpression(
- BinaryExpression(SyntaxKind.IsExpression, argIdentifier, wellKnownTypes.Grain.ToTypeSyntax()),
- InvocationExpression(argIdentifier.Member("AsReference".ToGenericName().AddTypeArgumentListArguments(arg.Type.ToTypeSyntax()))),
- argIdentifier);
- }
-
- return argIdentifier;
-
- string GetParameterName(IParameterSymbol parameter, int index)
- {
- var argName = parameter.Name;
- if (string.IsNullOrWhiteSpace(argName))
- {
- argName = string.Format(CultureInfo.InvariantCulture, "arg{0:G}", index);
- }
-
- return argName;
- }
- }
- }
-
- ///
- /// Returns syntax for the options argument to GrainReference.InvokeMethodAsync{T} and GrainReference.InvokeOneWayMethod.
- ///
- private static ArgumentSyntax GetInvokeOptions(WellKnownTypes wellKnownTypes, IMethodSymbol method)
- {
- var options = new List();
- var imo = wellKnownTypes.InvokeMethodOptions.ToNameSyntax();
- if (method.HasAttribute(wellKnownTypes.ReadOnlyAttribute))
- {
- options.Add(imo.Member("ReadOnly"));
- }
-
- if (method.HasAttribute(wellKnownTypes.UnorderedAttribute))
- {
- options.Add(imo.Member("Unordered"));
- }
-
- if (method.HasAttribute(wellKnownTypes.AlwaysInterleaveAttribute))
- {
- options.Add(imo.Member("AlwaysInterleave"));
- }
-
- if (method.GetAttribute(wellKnownTypes.TransactionAttribute, out var attr))
- {
- var enumType = wellKnownTypes.TransactionOption;
- var txRequirement = (int)attr.ConstructorArguments.First().Value;
- var values = enumType.GetMembers().OfType().ToList();
- var mapping = values.ToDictionary(m => (int) m.ConstantValue, m => m.Name);
- if (!mapping.TryGetValue(txRequirement, out var value))
- {
- throw new NotSupportedException($"Transaction requirement {txRequirement} on method {method} was not understood.");
- }
-
- switch (value)
- {
- case "Suppress":
- options.Add(imo.Member("TransactionSuppress"));
- break;
- case "CreateOrJoin":
- options.Add(imo.Member("TransactionCreateOrJoin"));
- break;
- case "Create":
- options.Add(imo.Member("TransactionCreate"));
- break;
- case "Join":
- options.Add(imo.Member("TransactionJoin"));
- break;
- case "Supported":
- options.Add(imo.Member("TransactionSupported"));
- break;
- case "NotAllowed":
- options.Add(imo.Member("TransactionNotAllowed"));
- break;
- default:
- throw new NotSupportedException($"Transaction requirement {value} on method {method} was not understood.");
- }
- }
-
- ExpressionSyntax allOptions;
- if (options.Count <= 1)
- {
- allOptions = options.FirstOrDefault();
- }
- else
- {
- allOptions =
- options.Aggregate((a, b) => BinaryExpression(SyntaxKind.BitwiseOrExpression, a, b));
- }
-
- if (allOptions == null)
- {
- return null;
- }
-
- return Argument(NameColon("options"), Token(SyntaxKind.None), allOptions);
- }
-
- private static MemberDeclarationSyntax GenerateIsCompatibleMethod(WellKnownTypes wellKnownTypes, GrainInterfaceDescription description)
- {
- var method = wellKnownTypes.GrainReference.Method("IsCompatible");
- var interfaceIdParameter = method.Parameters[0].Name.ToIdentifierName();
-
- var interfaceIds =
- new HashSet(
- new[] { description.InterfaceId }.Concat(
- description.Type.AllInterfaces.Where(wellKnownTypes.IsGrainInterface).Select(wellKnownTypes.GetTypeId)));
-
- var returnValue = default(BinaryExpressionSyntax);
- foreach (var interfaceId in interfaceIds)
- {
- var check = BinaryExpression(
- SyntaxKind.EqualsExpression,
- interfaceIdParameter,
- interfaceId.ToHexLiteral());
-
- // If this is the first check, assign it, otherwise OR this check with the previous checks.
- returnValue = returnValue == null
- ? check
- : BinaryExpression(SyntaxKind.LogicalOrExpression, returnValue, check);
- }
-
- return
- method.GetDeclarationSyntax()
- .AddModifiers(Token(SyntaxKind.OverrideKeyword))
- .WithExpressionBody(ArrowExpressionClause(returnValue))
- .WithSemicolonToken(Token(SyntaxKind.SemicolonToken));
- }
-
- private static MemberDeclarationSyntax GenerateInterfaceNameProperty(WellKnownTypes wellKnownTypes, GrainInterfaceDescription description)
- {
- var returnValue = description.Type.Name.ToLiteralExpression();
- return
- PropertyDeclaration(wellKnownTypes.String.ToTypeSyntax(), "InterfaceName")
- .WithExpressionBody(ArrowExpressionClause(returnValue))
- .AddModifiers(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.OverrideKeyword))
- .WithSemicolonToken(Token(SyntaxKind.SemicolonToken));
- }
-
- private static MethodDeclarationSyntax GenerateGetMethodNameMethod(WellKnownTypes wellKnownTypes, GrainInterfaceDescription description)
- {
- var method = wellKnownTypes.GrainReference.Method("GetMethodName");
- var methodDeclaration = method.GetDeclarationSyntax().AddModifiers(Token(SyntaxKind.OverrideKeyword));
- var parameters = method.Parameters;
-
- var interfaceIdArgument = parameters[0].Name.ToIdentifierName();
- var methodIdArgument = parameters[1].Name.ToIdentifierName();
-
- var callThrowMethodNotImplemented = InvocationExpression(IdentifierName("ThrowMethodNotImplemented"))
- .WithArgumentList(ArgumentList(SeparatedList(new[]
- {
- Argument(interfaceIdArgument),
- Argument(methodIdArgument)
- })));
-
- // This method is used directly after its declaration to create blocks for each interface id, comprising
- // primarily of a nested switch statement for each of the methods in the given interface.
- BlockSyntax ComposeInterfaceBlock(INamedTypeSymbol interfaceType, SwitchStatementSyntax methodSwitch)
- {
- return Block(methodSwitch.AddSections(SwitchSection()
- .AddLabels(DefaultSwitchLabel())
- .AddStatements(
- ExpressionStatement(callThrowMethodNotImplemented),
- ReturnStatement(LiteralExpression(SyntaxKind.NullLiteralExpression)))));
- }
-
- var interfaceCases = GrainInterfaceCommon.GenerateGrainInterfaceAndMethodSwitch(
- wellKnownTypes,
- description.Type,
- methodIdArgument,
- methodType => new StatementSyntax[] { ReturnStatement(methodType.Name.ToLiteralExpression()) },
- ComposeInterfaceBlock);
-
- // Generate the default case, which will throw a NotImplementedException.
- var callThrowInterfaceNotImplemented = InvocationExpression(IdentifierName("ThrowInterfaceNotImplemented"))
- .WithArgumentList(ArgumentList(SingletonSeparatedList(Argument(interfaceIdArgument))));
- var defaultCase = SwitchSection()
- .AddLabels(DefaultSwitchLabel())
- .AddStatements(
- ExpressionStatement(callThrowInterfaceNotImplemented),
- ReturnStatement(LiteralExpression(SyntaxKind.NullLiteralExpression)));
-
- var throwInterfaceNotImplemented = GrainInterfaceCommon.GenerateMethodNotImplementedFunction(wellKnownTypes);
- var throwMethodNotImplemented = GrainInterfaceCommon.GenerateInterfaceNotImplementedFunction(wellKnownTypes);
-
- var interfaceIdSwitch =
- SwitchStatement(interfaceIdArgument).AddSections(interfaceCases.ToArray()).AddSections(defaultCase);
- return methodDeclaration.AddBodyStatements(interfaceIdSwitch, throwInterfaceNotImplemented, throwMethodNotImplemented);
- }
- }
-}
diff --git a/src/Orleans.CodeGenerator/Generators/SerializerGenerator.cs b/src/Orleans.CodeGenerator/Generators/SerializerGenerator.cs
deleted file mode 100644
index e19282802d2..00000000000
--- a/src/Orleans.CodeGenerator/Generators/SerializerGenerator.cs
+++ /dev/null
@@ -1,835 +0,0 @@
-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using System.Text.RegularExpressions;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Orleans.CodeGenerator.Model;
-using Orleans.CodeGenerator.Utilities;
-using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-using ITypeSymbol = Microsoft.CodeAnalysis.ITypeSymbol;
-
-namespace Orleans.CodeGenerator.Generators
-{
- ///
- /// Code generator which generates serializers.
- /// Sample of generated serializer:
- /// [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Orleans-CodeGenerator", "2.0.0.0"), global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute, global::Orleans.CodeGeneration.SerializerAttribute(typeof(global::MyType))]
- /// internal sealed class OrleansCodeGenUnitTests_GrainInterfaces_MyTypeSerializer
- /// {
- /// private readonly global::System.Func<global::MyType, global::System.Int32> getField0;
- /// private readonly global::System.Action<global::MyType, global::System.Int32> setField0;
- /// public OrleansCodeGenUnitTests_GrainInterfaces_MyTypeSerializer(global::Orleans.Serialization.IFieldUtils fieldUtils)
- /// {
- /// [...]
- /// }
- /// [global::Orleans.CodeGeneration.CopierMethodAttribute]
- /// public global::System.Object DeepCopier(global::System.Object original, global::Orleans.Serialization.ICopyContext context)
- /// {
- /// [...]
- /// }
- /// [global::Orleans.CodeGeneration.SerializerMethodAttribute]
- /// public void Serializer(global::System.Object untypedInput, global::Orleans.Serialization.ISerializationContext context, global::System.Type expected)
- /// {
- /// [...]
- /// }
- /// [global::Orleans.CodeGeneration.DeserializerMethodAttribute]
- /// public global::System.Object Deserializer(global::System.Type expected, global::Orleans.Serialization.IDeserializationContext context)
- /// {
- /// [...]
- /// }
- ///}
- ///
- internal static class SerializerGenerator
- {
- ///
- /// The suffix appended to the name of generated classes.
- ///
- private const string ClassSuffix = "Serializer";
-
- private static readonly ConcurrentDictionary ShallowCopyableTypes = new ConcurrentDictionary();
-
- ///
- /// Returns the name of the generated class for the provided type.
- ///
- /// The type.
- /// The name of the generated class for the provided type.
- internal static string GetGeneratedClassName(INamedTypeSymbol type)
- {
- var parts = type.ToDisplayParts(SymbolDisplayFormat.FullyQualifiedFormat
- .WithGlobalNamespaceStyle(SymbolDisplayGlobalNamespaceStyle.Omitted)
- .WithMiscellaneousOptions(SymbolDisplayMiscellaneousOptions.None)
- .WithGenericsOptions(SymbolDisplayGenericsOptions.None)
- .WithKindOptions(SymbolDisplayKindOptions.None)
- .WithLocalOptions(SymbolDisplayLocalOptions.None)
- .WithMemberOptions(SymbolDisplayMemberOptions.None)
- .WithParameterOptions(SymbolDisplayParameterOptions.None));
- var b = new StringBuilder();
- foreach (var part in parts)
- {
- // Add the class prefix after the type name.
- switch (part.Kind)
- {
- case SymbolDisplayPartKind.Punctuation:
- b.Append('_');
- break;
- case SymbolDisplayPartKind.ClassName:
- case SymbolDisplayPartKind.InterfaceName:
- case SymbolDisplayPartKind.StructName:
- b.Append(part.ToString().TrimStart('@'));
- b.Append(ClassSuffix);
- break;
- default:
- b.Append(part.ToString().TrimStart('@'));
- break;
- }
- }
-
- return CodeGenerator.ToolName + b;
- }
-
- ///
- /// Generates the non static serializer class for the provided grain types.
- ///
- internal static (TypeDeclarationSyntax, TypeSyntax) GenerateClass(WellKnownTypes wellKnownTypes, SemanticModel model, SerializerTypeDescription description)
- {
- var className = GetGeneratedClassName(description.Target);
- var type = description.Target;
- var genericTypes = type.GetHierarchyTypeParameters().Select(_ => TypeParameter(_.ToString())).ToArray();
-
- var attributes = new List
- {
- GeneratedCodeAttributeGenerator.GetGeneratedCodeAttributeSyntax(wellKnownTypes),
- Attribute(wellKnownTypes.ExcludeFromCodeCoverageAttribute.ToNameSyntax()),
- Attribute(wellKnownTypes.SerializerAttribute.ToNameSyntax())
- .AddArgumentListArguments(
- AttributeArgument(TypeOfExpression(type.WithoutTypeParameters().ToTypeSyntax())))
- };
-
- var fields = GetFields(wellKnownTypes, model, type);
-
- var members = new List(GenerateFields(wellKnownTypes, fields))
- {
- GenerateConstructor(wellKnownTypes, className, fields),
- GenerateDeepCopierMethod(wellKnownTypes, type, fields, model),
- GenerateSerializerMethod(wellKnownTypes, type, fields, model),
- GenerateDeserializerMethod(wellKnownTypes, type, fields, model),
- };
-
- var classDeclaration =
- ClassDeclaration(className)
- .AddModifiers(Token(SyntaxKind.InternalKeyword))
- .AddModifiers(Token(SyntaxKind.SealedKeyword))
- .AddAttributeLists(AttributeList().AddAttributes(attributes.ToArray()))
- .AddMembers(members.ToArray())
- .AddConstraintClauses(type.GetTypeConstraintSyntax());
- if (genericTypes.Length > 0)
- {
- classDeclaration = classDeclaration.AddTypeParameterListParameters(genericTypes);
- }
-
- return (classDeclaration, ParseTypeName(type.GetParsableReplacementName(className)));
- }
-
- private static MemberDeclarationSyntax GenerateConstructor(WellKnownTypes wellKnownTypes, string className, List fields)
- {
- var body = new List();
-
- // Expressions for specifying binding flags.
- var bindingFlags = SymbolSyntaxExtensions.GetBindingFlagsParenthesizedExpressionSyntax(
- SyntaxKind.BitwiseOrExpression,
- BindingFlags.Instance,
- BindingFlags.NonPublic,
- BindingFlags.Public);
-
- var fieldUtils = IdentifierName("fieldUtils");
-
- foreach (var field in fields)
- {
- // Get the field
- var fieldInfoField = IdentifierName(field.InfoFieldName);
- var fieldInfo =
- InvocationExpression(TypeOfExpression(field.Field.ContainingType.ToTypeSyntax()).Member("GetField"))
- .AddArgumentListArguments(
- Argument(field.Field.Name.ToLiteralExpression()),
- Argument(bindingFlags));
- var fieldInfoVariable =
- VariableDeclarator(field.InfoFieldName).WithInitializer(EqualsValueClause(fieldInfo));
-
- if (!field.IsGettableProperty || !field.IsSettableProperty)
- {
- body.Add(LocalDeclarationStatement(
- VariableDeclaration(wellKnownTypes.FieldInfo.ToTypeSyntax()).AddVariables(fieldInfoVariable)));
- }
-
- // Set the getter/setter of the field
- if (!field.IsGettableProperty)
- {
- var getterType = wellKnownTypes.Func_2.Construct(field.Field.ContainingType, field.SafeType).ToTypeSyntax();
-
- var getterInvoke = CastExpression(
- getterType,
- InvocationExpression(fieldUtils.Member("GetGetter")).AddArgumentListArguments(Argument(fieldInfoField)));
-
- body.Add(ExpressionStatement(
- AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, IdentifierName(field.GetterFieldName), getterInvoke)));
- }
-
- if (!field.IsSettableProperty)
- {
- if (field.Field.ContainingType != null && field.Field.ContainingType.IsValueType)
- {
- var setterType = wellKnownTypes.ValueTypeSetter_2.Construct(field.Field.ContainingType, field.SafeType).ToTypeSyntax();
-
- var getValueSetterInvoke = CastExpression(
- setterType,
- InvocationExpression(fieldUtils.Member("GetValueSetter"))
- .AddArgumentListArguments(Argument(fieldInfoField)));
-
- body.Add(ExpressionStatement(
- AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, IdentifierName(field.SetterFieldName), getValueSetterInvoke)));
- }
- else
- {
- var setterType = wellKnownTypes.Action_2.Construct(field.Field.ContainingType, field.SafeType).ToTypeSyntax();
-
- var getReferenceSetterInvoke = CastExpression(
- setterType,
- InvocationExpression(fieldUtils.Member("GetReferenceSetter"))
- .AddArgumentListArguments(Argument(fieldInfoField)));
-
- body.Add(ExpressionStatement(
- AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, IdentifierName(field.SetterFieldName), getReferenceSetterInvoke)));
- }
- }
-
- }
-
- return
- ConstructorDeclaration(className)
- .AddModifiers(Token(SyntaxKind.PublicKeyword))
- .AddParameterListParameters(
- Parameter(fieldUtils.Identifier).WithType(wellKnownTypes.IFieldUtils.ToTypeSyntax()))
- .AddBodyStatements(body.ToArray());
- }
-
- ///
- /// Returns syntax for the deserializer method.
- ///
- private static MemberDeclarationSyntax GenerateDeserializerMethod(WellKnownTypes wellKnownTypes, INamedTypeSymbol type, List fields, SemanticModel model)
- {
- var contextParameter = IdentifierName("context");
-
- var resultDeclaration =
- LocalDeclarationStatement(
- VariableDeclaration(type.ToTypeSyntax())
- .AddVariables(
- VariableDeclarator("result")
- .WithInitializer(EqualsValueClause(GetObjectCreationExpressionSyntax(wellKnownTypes, type, model)))));
- var resultVariable = IdentifierName("result");
-
- var body = new List {resultDeclaration};
-
- // Value types cannot be referenced, only copied, so there is no need to box & record instances of value types.
- if (!type.IsValueType)
- {
- // Record the result for cyclic deserialization.
- var currentSerializationContext = contextParameter;
- body.Add(
- ExpressionStatement(
- InvocationExpression(currentSerializationContext.Member("RecordObject"))
- .AddArgumentListArguments(Argument(resultVariable))));
- }
-
- // Deserialize all fields.
- foreach (var field in fields)
- {
- var deserialized =
- InvocationExpression(contextParameter.Member("DeserializeInner"))
- .AddArgumentListArguments(
- Argument(TypeOfExpression(field.Type)));
- body.Add(
- ExpressionStatement(
- field.GetSetter(
- resultVariable,
- CastExpression(field.Type, deserialized))));
- }
-
- // If the type implements the internal IOnDeserialized lifecycle method, invoke it's method now.
- if (type.HasInterface(wellKnownTypes.IOnDeserialized))
- {
- // C#: ((IOnDeserialized)result).OnDeserialized(context);
- var typedResult = ParenthesizedExpression(CastExpression(wellKnownTypes.IOnDeserialized.ToTypeSyntax(), resultVariable));
- var invokeOnDeserialized = InvocationExpression(typedResult.Member("OnDeserialized"))
- .AddArgumentListArguments(Argument(contextParameter));
- body.Add(ExpressionStatement(invokeOnDeserialized));
- }
-
- body.Add(ReturnStatement(CastExpression(type.ToTypeSyntax(), resultVariable)));
- return
- MethodDeclaration(wellKnownTypes.Object.ToTypeSyntax(), "Deserializer")
- .AddModifiers(Token(SyntaxKind.PublicKeyword))
- .AddParameterListParameters(
- Parameter(Identifier("expected")).WithType(wellKnownTypes.Type.ToTypeSyntax()),
- Parameter(Identifier("context")).WithType(wellKnownTypes.IDeserializationContext.ToTypeSyntax()))
- .AddBodyStatements(body.ToArray())
- .AddAttributeLists(
- AttributeList()
- .AddAttributes(Attribute(wellKnownTypes.DeserializerMethodAttribute.ToNameSyntax())));
- }
-
- private static MemberDeclarationSyntax GenerateSerializerMethod(WellKnownTypes wellKnownTypes, INamedTypeSymbol type, List fields, SemanticModel model)
- {
- var contextParameter = IdentifierName("context");
-
- var body = new List
- {
- LocalDeclarationStatement(
- VariableDeclaration(type.ToTypeSyntax())
- .AddVariables(
- VariableDeclarator("input")
- .WithInitializer(
- EqualsValueClause(
- CastExpression(type.ToTypeSyntax(), IdentifierName("untypedInput"))))))
- };
-
- var inputExpression = IdentifierName("input");
-
- // Serialize all members.
- foreach (var field in fields)
- {
- body.Add(
- ExpressionStatement(
- InvocationExpression(contextParameter.Member("SerializeInner"))
- .AddArgumentListArguments(
- Argument(field.GetGetter(inputExpression, forceAvoidCopy: true)),
- Argument(TypeOfExpression(field.Type)))));
- }
-
- return
- MethodDeclaration(wellKnownTypes.Void.ToTypeSyntax(), "Serializer")
- .AddModifiers(Token(SyntaxKind.PublicKeyword))
- .AddParameterListParameters(
- Parameter(Identifier("untypedInput")).WithType(wellKnownTypes.Object.ToTypeSyntax()),
- Parameter(Identifier("context")).WithType(wellKnownTypes.ISerializationContext.ToTypeSyntax()),
- Parameter(Identifier("expected")).WithType(wellKnownTypes.Type.ToTypeSyntax()))
- .AddBodyStatements(body.ToArray())
- .AddAttributeLists(
- AttributeList()
- .AddAttributes(Attribute(wellKnownTypes.SerializerMethodAttribute.ToNameSyntax())));
- }
-
- ///
- /// Returns syntax for the deep copy method.
- ///
- private static MemberDeclarationSyntax GenerateDeepCopierMethod(WellKnownTypes wellKnownTypes, INamedTypeSymbol type, List fields, SemanticModel model)
- {
- var originalVariable = IdentifierName("original");
- var inputVariable = IdentifierName("input");
- var resultVariable = IdentifierName("result");
-
- var body = new List();
- if (type.HasInterface(wellKnownTypes.ImmutableAttribute))
- {
- // Immutable types do not require copying.
- var typeName = type.ToDisplayString();
- var comment = Comment($"// No deep copy required since {typeName} is marked with the [Immutable] attribute.");
- body.Add(ReturnStatement(originalVariable).WithLeadingTrivia(comment));
- }
- else
- {
- body.Add(
- LocalDeclarationStatement(
- VariableDeclaration(type.ToTypeSyntax())
- .AddVariables(
- VariableDeclarator("input")
- .WithInitializer(
- EqualsValueClause(
- ParenthesizedExpression(
- CastExpression(type.ToTypeSyntax(), originalVariable)))))));
- body.Add(
- LocalDeclarationStatement(
- VariableDeclaration(type.ToTypeSyntax())
- .AddVariables(
- VariableDeclarator("result")
- .WithInitializer(EqualsValueClause(GetObjectCreationExpressionSyntax(wellKnownTypes, type, model))))));
-
- // Record this serialization.
- var context = IdentifierName("context");
- body.Add(
- ExpressionStatement(
- InvocationExpression(context.Member("RecordCopy"))
- .AddArgumentListArguments(Argument(originalVariable), Argument(resultVariable))));
-
- // Copy all members from the input to the result.
- foreach (var field in fields)
- {
- body.Add(ExpressionStatement(field.GetSetter(resultVariable, field.GetGetter(inputVariable, context))));
- }
-
- body.Add(ReturnStatement(resultVariable));
- }
-
- return
- MethodDeclaration(wellKnownTypes.Object.ToTypeSyntax(), "DeepCopier")
- .AddModifiers(Token(SyntaxKind.PublicKeyword))
- .AddParameterListParameters(
- Parameter(Identifier("original")).WithType(wellKnownTypes.Object.ToTypeSyntax()),
- Parameter(Identifier("context")).WithType(wellKnownTypes.ICopyContext.ToTypeSyntax()))
- .AddBodyStatements(body.ToArray())
- .AddAttributeLists(
- AttributeList().AddAttributes(Attribute(wellKnownTypes.CopierMethodAttribute.ToNameSyntax())));
- }
-
- ///
- /// Returns syntax for the static fields of the serializer class.
- ///
- private static MemberDeclarationSyntax[] GenerateFields(WellKnownTypes wellKnownTypes, List fields)
- {
- var result = new List();
-
- // Add each field and initialize it.
- foreach (var field in fields)
- {
- // Declare the getter for this field.
- if (!field.IsGettableProperty)
- {
- var getterType = wellKnownTypes.Func_2.Construct(field.Field.ContainingType, field.SafeType).ToTypeSyntax();
- var fieldGetterVariable = VariableDeclarator(field.GetterFieldName);
-
- result.Add(
- FieldDeclaration(VariableDeclaration(getterType).AddVariables(fieldGetterVariable))
- .AddModifiers(
- Token(SyntaxKind.PrivateKeyword),
- Token(SyntaxKind.ReadOnlyKeyword)));
- }
-
- if (!field.IsSettableProperty)
- {
- if (field.Field.ContainingType != null && field.Field.ContainingType.IsValueType)
- {
- var setterType = wellKnownTypes.ValueTypeSetter_2.Construct(field.Field.ContainingType, field.SafeType).ToTypeSyntax();
- var fieldSetterVariable = VariableDeclarator(field.SetterFieldName);
-
- result.Add(
- FieldDeclaration(VariableDeclaration(setterType).AddVariables(fieldSetterVariable))
- .AddModifiers(
- Token(SyntaxKind.PrivateKeyword),
- Token(SyntaxKind.ReadOnlyKeyword)));
- }
- else
- {
- var setterType = wellKnownTypes.Action_2.Construct(field.Field.ContainingType, field.SafeType).ToTypeSyntax();
- var fieldSetterVariable = VariableDeclarator(field.SetterFieldName);
-
- result.Add(
- FieldDeclaration(VariableDeclaration(setterType).AddVariables(fieldSetterVariable))
- .AddModifiers(
- Token(SyntaxKind.PrivateKeyword),
- Token(SyntaxKind.ReadOnlyKeyword)));
- }
- }
- }
-
- return result.ToArray();
- }
-
-
- ///
- /// Returns syntax for initializing a new instance of the provided type.
- ///
- private static ExpressionSyntax GetObjectCreationExpressionSyntax(WellKnownTypes wellKnownTypes, INamedTypeSymbol type, SemanticModel model)
- {
- ExpressionSyntax result;
-
- if (type.IsValueType)
- {
- // Use the default value.
- result = DefaultExpression(type.ToTypeSyntax());
- }
- else if (GetEmptyConstructor(type, model) != null)
- {
- // Use the default constructor.
- result = ObjectCreationExpression(type.ToTypeSyntax()).AddArgumentListArguments();
- }
- else
- {
- // Create an unformatted object.
- result = CastExpression(
- type.ToTypeSyntax(),
- InvocationExpression(wellKnownTypes.FormatterServices.ToTypeSyntax().Member("GetUninitializedObject"))
- .AddArgumentListArguments(
- Argument(TypeOfExpression(type.ToTypeSyntax()))));
- }
-
- return result;
- }
-
- ///
- /// Return the default constructor on if found or null if not found.
- ///
- private static IMethodSymbol GetEmptyConstructor(INamedTypeSymbol type, SemanticModel model)
- {
- return type.GetMembers()
- .OfType()
- .FirstOrDefault(method => method.MethodKind == MethodKind.Constructor && method.Parameters.Length == 0 && model.IsAccessible(0, method));
- }
-
- ///
- /// Returns a sorted list of the fields of the provided type.
- ///
- private static List GetFields(WellKnownTypes wellKnownTypes, SemanticModel model, INamedTypeSymbol type)
- {
- var result =
- type.GetAllMembers()
- .Where(f => ShouldSerializeField(wellKnownTypes, f))
- .Select((info, i) => new FieldInfoMember(wellKnownTypes, model, type, info, i))
- .ToList();
- result.Sort(FieldInfoMember.Comparer.Instance);
- return result;
- }
-
- ///
- /// Returns if the provided field should be serialized, otherwise.
- ///
- public static bool ShouldSerializeField(WellKnownTypes wellKnownTypes, IFieldSymbol symbol)
- {
- if (symbol.IsStatic) return false;
- if (symbol.HasAttribute(wellKnownTypes.NonSerializedAttribute)) return false;
-
- ITypeSymbol fieldType = symbol.Type;
-
- if (fieldType.TypeKind == TypeKind.Pointer) return false;
- if (fieldType.TypeKind == TypeKind.Delegate) return false;
-
- if (wellKnownTypes.IntPtr.Equals(fieldType)) return false;
- if (wellKnownTypes.UIntPtr.Equals(fieldType)) return false;
-
- if (symbol.ContainingType.HasBaseType(wellKnownTypes.MarshalByRefObject)) return false;
-
- return true;
- }
-
- internal static bool IsOrleansShallowCopyable(WellKnownTypes wellKnownTypes, ITypeSymbol type)
- {
- var root = new HashSet();
- return IsOrleansShallowCopyable(wellKnownTypes, type, root);
- }
-
- internal static bool IsOrleansShallowCopyable(WellKnownTypes wellKnownTypes, ITypeSymbol type, HashSet examining)
- {
- switch (type.SpecialType)
- {
- case SpecialType.System_Boolean:
- case SpecialType.System_Char:
- case SpecialType.System_SByte:
- case SpecialType.System_Byte:
- case SpecialType.System_Int16:
- case SpecialType.System_UInt16:
- case SpecialType.System_Int32:
- case SpecialType.System_UInt32:
- case SpecialType.System_Int64:
- case SpecialType.System_UInt64:
- case SpecialType.System_Decimal:
- case SpecialType.System_Single:
- case SpecialType.System_Double:
- case SpecialType.System_String:
- case SpecialType.System_DateTime:
- return true;
- }
-
- if (wellKnownTypes.TimeSpan.Equals(type)
- || wellKnownTypes.IPAddress.Equals(type)
- || wellKnownTypes.IPEndPoint.Equals(type)
- || wellKnownTypes.SiloAddress.Equals(type)
- || wellKnownTypes.GrainId.Equals(type)
- || wellKnownTypes.ActivationId.Equals(type)
- || wellKnownTypes.ActivationAddress.Equals(type)
- || wellKnownTypes.CorrelationId is WellKnownTypes.Some correlationIdType && correlationIdType.Value.Equals(type)
- || wellKnownTypes.CancellationToken.Equals(type)) return true;
-
- if (ShallowCopyableTypes.TryGetValue(type, out var result)) return result;
-
- if (type.HasAttribute(wellKnownTypes.ImmutableAttribute))
- {
- return ShallowCopyableTypes[type] = true;
- }
-
- if (type.HasBaseType(wellKnownTypes.Exception))
- {
- return ShallowCopyableTypes[type] = true;
- }
-
- if (!(type is INamedTypeSymbol namedType))
- {
- return ShallowCopyableTypes[type] = false;
- }
-
- if (namedType.IsGenericType && wellKnownTypes.Immutable_1.Equals(namedType.ConstructedFrom))
- {
- return ShallowCopyableTypes[type] = true;
- }
-
- if (type.TypeKind == TypeKind.Struct && !namedType.IsGenericType && !namedType.IsUnboundGenericType)
- {
- return ShallowCopyableTypes[type] = IsValueTypeFieldsShallowCopyable(wellKnownTypes, type, examining);
- }
-
- return ShallowCopyableTypes[type] = false;
- }
-
- private static bool IsValueTypeFieldsShallowCopyable(WellKnownTypes wellKnownTypes, ITypeSymbol type, HashSet examining)
- {
- foreach (var field in type.GetAllMembers())
- {
- if (!(field.Type is INamedTypeSymbol fieldType))
- {
- throw new NotSupportedException(
- $"Field {field} in type {type} is not an {nameof(INamedTypeSymbol)} and therefore is not supported. Type is {field.Type.GetType()}");
- }
-
- if (type.Equals(fieldType)) return false;
-
- if (!IsOrleansShallowCopyable(wellKnownTypes, fieldType, examining)) return false;
- }
-
- return true;
- }
-
- ///
- /// Represents a field.
- ///
- private class FieldInfoMember
- {
- private readonly SemanticModel model;
- private readonly WellKnownTypes wellKnownTypes;
- private readonly INamedTypeSymbol targetType;
- private IPropertySymbol property;
-
- ///
- /// The ordinal assigned to this field.
- ///
- private readonly int ordinal;
-
- public FieldInfoMember(WellKnownTypes wellKnownTypes, SemanticModel model, INamedTypeSymbol targetType, IFieldSymbol field, int ordinal)
- {
- this.wellKnownTypes = wellKnownTypes;
- this.model = model;
- this.targetType = targetType;
- this.Field = field;
- this.ordinal = ordinal;
- }
-
- ///
- /// Gets the underlying instance.
- ///
- public IFieldSymbol Field { get; }
-
- ///
- /// Gets a usable representation of the field type.
- ///
- ///
- /// If the field is of type 'dynamic', we represent it as 'object' because 'dynamic' cannot appear in typeof expressions.
- ///
- public ITypeSymbol SafeType => this.Field.Type.TypeKind == TypeKind.Dynamic
- ? this.wellKnownTypes.Object
- : this.Field.Type;
-
- ///
- /// Gets the name of the field info field.
- ///
- public string InfoFieldName => "field" + this.ordinal;
-
- ///
- /// Gets the name of the getter field.
- ///
- public string GetterFieldName => "getField" + this.ordinal;
-
- ///
- /// Gets the name of the setter field.
- ///
- public string SetterFieldName => "setField" + this.ordinal;
-
- ///
- /// Gets a value indicating whether or not this field represents a property with an accessible, non-obsolete getter.
- ///
- public bool IsGettableProperty => this.Property?.GetMethod != null && this.model.IsAccessible(0, this.Property.GetMethod) && !this.IsObsolete;
-
- ///
- /// Gets a value indicating whether or not this field represents a property with an accessible, non-obsolete setter.
- ///
- public bool IsSettableProperty => this.Property?.SetMethod != null && this.model.IsAccessible(0, this.Property.SetMethod) && !this.IsObsolete;
-
- ///
- /// Gets syntax representing the type of this field.
- ///
- public TypeSyntax Type => this.SafeType.ToTypeSyntax();
-
- ///
- /// Gets the which this field is the backing property for, or
- /// if this is not the backing field of an auto-property.
- ///
- private IPropertySymbol Property
- {
- get
- {
- if (this.property != null)
- {
- return this.property;
- }
-
- var propertyName = Regex.Match(this.Field.Name, "^<([^>]+)>.*$");
- if (!propertyName.Success || this.Field.ContainingType == null) return null;
-
- var name = propertyName.Groups[1].Value;
- var candidates = this.targetType
- .GetAllMembers()
- .Where(p => string.Equals(name, p.Name, StringComparison.Ordinal) && !p.IsAbstract)
- .ToArray();
-
- if (candidates.Length > 1) return null;
- if (!this.SafeType.Equals(candidates[0].Type)) return null;
-
- return this.property = candidates[0];
- }
- }
-
- ///
- /// Gets a value indicating whether or not this field is obsolete.
- ///
- private bool IsObsolete => this.Field.HasAttribute(this.wellKnownTypes.ObsoleteAttribute) ||
- this.Property != null && this.Property.HasAttribute(this.wellKnownTypes.ObsoleteAttribute);
-
- ///
- /// Returns syntax for retrieving the value of this field, deep copying it if necessary.
- ///
- /// The instance of the containing type.
- /// The expression used to retrieve the serialization context.
- /// Whether or not to ensure that no copy of the field is made.
- /// Syntax for retrieving the value of this field.
- public ExpressionSyntax GetGetter(ExpressionSyntax instance, ExpressionSyntax serializationContextExpression = null, bool forceAvoidCopy = false)
- {
- // Retrieve the value of the field.
- var getValueExpression = this.GetValueExpression(instance);
-
- // Avoid deep-copying the field if possible.
- if (forceAvoidCopy || IsOrleansShallowCopyable(this.wellKnownTypes, this.SafeType))
- {
- // Return the value without deep-copying it.
- return getValueExpression;
- }
-
- // Addressable arguments must be converted to references before passing.
- // IGrainObserver instances cannot be directly converted to references, therefore they are not included.
- ExpressionSyntax deepCopyValueExpression;
- if (this.SafeType.HasInterface(this.wellKnownTypes.IAddressable) &&
- this.SafeType.TypeKind == TypeKind.Interface &&
- !this.SafeType.HasInterface(this.wellKnownTypes.IGrainObserver))
- {
- var getAsReference = getValueExpression.Member("AsReference".ToGenericName().AddTypeArgumentListArguments(this.Type));
-
- // If the value is not a GrainReference, convert it to a strongly-typed GrainReference.
- // C#: (value == null || value is GrainReference) ? value : value.AsReference()
- deepCopyValueExpression =
- ConditionalExpression(
- ParenthesizedExpression(
- BinaryExpression(
- SyntaxKind.LogicalOrExpression,
- BinaryExpression(
- SyntaxKind.EqualsExpression,
- getValueExpression,
- LiteralExpression(SyntaxKind.NullLiteralExpression)),
- BinaryExpression(
- SyntaxKind.IsExpression,
- getValueExpression,
- this.wellKnownTypes.GrainReference.ToTypeSyntax()))),
- getValueExpression,
- InvocationExpression(getAsReference));
- }
- else
- {
- deepCopyValueExpression = getValueExpression;
- }
-
- // Deep-copy the value.
- return CastExpression(
- this.Type,
- InvocationExpression(serializationContextExpression.Member("DeepCopyInner"))
- .AddArgumentListArguments(
- Argument(deepCopyValueExpression)));
- }
-
- ///
- /// Returns syntax for setting the value of this field.
- ///
- /// The instance of the containing type.
- /// Syntax for the new value.
- /// Syntax for setting the value of this field.
- public ExpressionSyntax GetSetter(ExpressionSyntax instance, ExpressionSyntax value)
- {
- // If the field is the backing field for an accessible auto-property use the property directly.
- if (this.IsSettableProperty)
- {
- return AssignmentExpression(
- SyntaxKind.SimpleAssignmentExpression,
- instance.Member(this.Property.Name),
- value);
- }
-
- var instanceArg = Argument(instance);
- if (this.Field.ContainingType != null && this.Field.ContainingType.IsValueType)
- {
- instanceArg = instanceArg.WithRefOrOutKeyword(Token(SyntaxKind.RefKeyword));
- }
-
- return
- InvocationExpression(IdentifierName(this.SetterFieldName))
- .AddArgumentListArguments(instanceArg, Argument(value));
- }
-
- ///
- /// Returns syntax for retrieving the value of this field.
- ///
- /// The instance of the containing type.
- /// Syntax for retrieving the value of this field.
- private ExpressionSyntax GetValueExpression(ExpressionSyntax instance)
- {
- // If the field is the backing field for an accessible auto-property use the property directly.
- ExpressionSyntax result;
- if (this.IsGettableProperty)
- {
- result = instance.Member(this.Property.Name);
- }
- else
- {
- // Retrieve the field using the generated getter.
- result =
- InvocationExpression(IdentifierName(this.GetterFieldName))
- .AddArgumentListArguments(Argument(instance));
- }
-
- return result;
- }
-
- ///
- /// A comparer for which compares by name.
- ///
- public class Comparer : IComparer
- {
- ///
- /// Gets the singleton instance of this class.
- ///
- public static Comparer Instance { get; } = new Comparer();
-
- public int Compare(FieldInfoMember x, FieldInfoMember y)
- {
- return string.Compare(x?.Field.Name, y?.Field.Name, StringComparison.Ordinal);
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator/Model/AggregatedModel.cs b/src/Orleans.CodeGenerator/Model/AggregatedModel.cs
deleted file mode 100644
index 76eafc2c3f1..00000000000
--- a/src/Orleans.CodeGenerator/Model/AggregatedModel.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System.Collections.Generic;
-
-namespace Orleans.CodeGenerator.Model
-{
- internal class AggregatedModel
- {
- public List GrainClasses { get; } = new List();
- public List GrainInterfaces { get; } = new List();
- public SerializationTypeDescriptions Serializers { get; } = new SerializationTypeDescriptions();
- }
-}
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator/Model/GrainClassDescription.cs b/src/Orleans.CodeGenerator/Model/GrainClassDescription.cs
deleted file mode 100644
index 16729b29a91..00000000000
--- a/src/Orleans.CodeGenerator/Model/GrainClassDescription.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using Microsoft.CodeAnalysis;
-
-namespace Orleans.CodeGenerator.Model
-{
- internal class GrainClassDescription : ITypeDescription
- {
- public GrainClassDescription(INamedTypeSymbol type, int typeCode)
- {
- this.Type = type;
- this.TypeCode = typeCode;
- }
-
- public int TypeCode { get; }
-
- public INamedTypeSymbol Type { get; }
- }
-}
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator/Model/GrainInterfaceDescription.cs b/src/Orleans.CodeGenerator/Model/GrainInterfaceDescription.cs
deleted file mode 100644
index 4ab8360083f..00000000000
--- a/src/Orleans.CodeGenerator/Model/GrainInterfaceDescription.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Orleans.CodeGenerator.Generators;
-using Orleans.CodeGenerator.Utilities;
-using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-
-namespace Orleans.CodeGenerator.Model
-{
- internal class GrainInterfaceDescription : ITypeDescription
- {
- public GrainInterfaceDescription(INamedTypeSymbol type, int interfaceId, ushort interfaceVersion, IEnumerable members)
- {
- this.Type = type;
- this.InterfaceId = interfaceId;
- this.InterfaceVersion = interfaceVersion;
- this.Methods = members.ToList();
- }
-
- public ushort InterfaceVersion { get; }
-
- public int InterfaceId { get; }
-
- public INamedTypeSymbol Type { get; }
-
- public List Methods { get; }
-
- public string InvokerTypeName => GrainMethodInvokerGenerator.GetGeneratedClassName(this.Type);
- public string ReferenceTypeName => GrainReferenceGenerator.GetGeneratedClassName(this.Type);
-
- public TypeSyntax InvokerType => ParseTypeName(this.Type.GetParsableReplacementName(this.InvokerTypeName));
- public TypeSyntax ReferenceType => ParseTypeName(this.Type.GetParsableReplacementName(this.ReferenceTypeName));
- }
-}
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator/Model/GrainMethodDescription.cs b/src/Orleans.CodeGenerator/Model/GrainMethodDescription.cs
deleted file mode 100644
index f45f2c381f1..00000000000
--- a/src/Orleans.CodeGenerator/Model/GrainMethodDescription.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using Microsoft.CodeAnalysis;
-
-namespace Orleans.CodeGenerator.Model
-{
- internal class GrainMethodDescription
- {
- public GrainMethodDescription(int methodId, IMethodSymbol method)
- {
- this.MethodId = methodId;
- this.Method = method;
- }
-
- public int MethodId { get; }
- public IMethodSymbol Method { get; }
- }
-}
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator/Model/ITypeDescription.cs b/src/Orleans.CodeGenerator/Model/ITypeDescription.cs
deleted file mode 100644
index 0c3993155b9..00000000000
--- a/src/Orleans.CodeGenerator/Model/ITypeDescription.cs
+++ /dev/null
@@ -1,4 +0,0 @@
-namespace Orleans.CodeGenerator.Model
-{
- internal interface ITypeDescription { }
-}
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator/Model/SerializationTypeDescriptions.cs b/src/Orleans.CodeGenerator/Model/SerializationTypeDescriptions.cs
deleted file mode 100644
index 434a503ab42..00000000000
--- a/src/Orleans.CodeGenerator/Model/SerializationTypeDescriptions.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-using System;
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-
-namespace Orleans.CodeGenerator.Model
-{
- internal class SerializationTypeDescriptions
- {
- public List SerializerTypes { get; } = new List();
- public HashSet KnownTypes { get; } = new HashSet(KnownTypeDescription.Comparer);
- }
-
- internal class SerializerTypeDescription
- {
- public bool OverrideExistingSerializer { get; set; }
-
- private INamedTypeSymbol target;
-
- public TypeSyntax SerializerTypeSyntax { get; set; }
-
- public INamedTypeSymbol Target
- {
- get => target;
- set => this.target = value?.OriginalDefinition?.ConstructedFrom;
- }
-
- public static IEqualityComparer TargetComparer { get; } = new TargetEqualityComparer();
-
- private sealed class TargetEqualityComparer : IEqualityComparer
- {
- public bool Equals(SerializerTypeDescription x, SerializerTypeDescription y)
- {
- if (ReferenceEquals(x, y)) return true;
- if (ReferenceEquals(x, null)) return false;
- if (ReferenceEquals(y, null)) return false;
- if (x.GetType() != y.GetType()) return false;
- return Equals(x.Target, y.Target);
- }
-
- public int GetHashCode(SerializerTypeDescription obj)
- {
- return obj.Target != null ? obj.Target.GetHashCode() : 0;
- }
- }
- }
-
- public class KnownTypeDescription
- {
- private sealed class TypeTypeKeyEqualityComparer : IEqualityComparer
- {
- public bool Equals(KnownTypeDescription x, KnownTypeDescription y)
- {
- if (ReferenceEquals(x, y)) return true;
- if (ReferenceEquals(x, null)) return false;
- if (ReferenceEquals(y, null)) return false;
- if (x.GetType() != y.GetType()) return false;
- return Equals(x.type, y.type) && string.Equals(x.TypeKey, y.TypeKey);
- }
-
- public int GetHashCode(KnownTypeDescription obj)
- {
- unchecked
- {
- return ((obj.type != null ? obj.type.GetHashCode() : 0) * 397) ^ (obj.TypeKey != null ? obj.TypeKey.GetHashCode() : 0);
- }
- }
- }
-
- public static IEqualityComparer Comparer { get; } = new TypeTypeKeyEqualityComparer();
-
- private INamedTypeSymbol type;
-
- public INamedTypeSymbol Type
- {
- get => type;
- set => type = value?.OriginalDefinition?.ConstructedFrom;
- }
-
- public string TypeKey { get; set; }
- }
-}
diff --git a/src/Orleans.CodeGenerator/Orleans.CodeGenerator.csproj b/src/Orleans.CodeGenerator/Orleans.CodeGenerator.csproj
deleted file mode 100644
index 10361143d5c..00000000000
--- a/src/Orleans.CodeGenerator/Orleans.CodeGenerator.csproj
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
- Orleans.CodeGenerator
- Orleans.CodeGenerator
- Microsoft.Orleans.CodeGenerator
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator/Properties/AssemblyInfo.cs b/src/Orleans.CodeGenerator/Properties/AssemblyInfo.cs
deleted file mode 100644
index 55211ca9cf7..00000000000
--- a/src/Orleans.CodeGenerator/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,3 +0,0 @@
-using System.Runtime.CompilerServices;
-
-[assembly: InternalsVisibleTo("CodeGenerator.Tests")]
diff --git a/src/Orleans.CodeGenerator/Utilities/Identifier.cs b/src/Orleans.CodeGenerator/Utilities/Identifier.cs
deleted file mode 100644
index c21ab220087..00000000000
--- a/src/Orleans.CodeGenerator/Utilities/Identifier.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-namespace Orleans.CodeGenerator.Utilities
-{
- internal static class Identifier
- {
- internal static bool IsCSharpKeyword(string identifier)
- {
- switch (identifier)
- {
- case "abstract":
- case "add":
- case "alias":
- case "as":
- case "ascending":
- case "async":
- case "await":
- case "base":
- case "bool":
- case "break":
- case "byte":
- case "case":
- case "catch":
- case "char":
- case "checked":
- case "class":
- case "const":
- case "continue":
- case "decimal":
- case "default":
- case "delegate":
- case "descending":
- case "do":
- case "double":
- case "dynamic":
- case "else":
- case "enum":
- case "event":
- case "explicit":
- case "extern":
- case "false":
- case "finally":
- case "fixed":
- case "float":
- case "for":
- case "foreach":
- case "from":
- case "get":
- case "global":
- case "goto":
- case "group":
- case "if":
- case "implicit":
- case "in":
- case "int":
- case "interface":
- case "internal":
- case "into":
- case "is":
- case "join":
- case "let":
- case "lock":
- case "long":
- case "nameof":
- case "namespace":
- case "new":
- case "null":
- case "object":
- case "operator":
- case "orderby":
- case "out":
- case "override":
- case "params":
- case "partial":
- case "private":
- case "protected":
- case "public":
- case "readonly":
- case "ref":
- case "remove":
- case "return":
- case "sbyte":
- case "sealed":
- case "select":
- case "set":
- case "short":
- case "sizeof":
- case "stackalloc":
- case "static":
- case "string":
- case "struct":
- case "switch":
- case "this":
- case "throw":
- case "true":
- case "try":
- case "typeof":
- case "uint":
- case "ulong":
- case "unchecked":
- case "unsafe":
- case "ushort":
- case "using":
- case "value":
- case "var":
- case "virtual":
- case "void":
- case "volatile":
- case "when":
- case "where":
- case "while":
- case "yield":
- return true;
- default:
- return false;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator/Utilities/LiteralExtensions.cs b/src/Orleans.CodeGenerator/Utilities/LiteralExtensions.cs
deleted file mode 100644
index 3634d23d05e..00000000000
--- a/src/Orleans.CodeGenerator/Utilities/LiteralExtensions.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-
-namespace Orleans.CodeGenerator.Utilities
-{
- ///
- /// Extensions to the generate syntax for literals.
- ///
- internal static class LiteralExtensions
- {
- ///
- /// Returns the provided string as a literal expression.
- ///
- public static LiteralExpressionSyntax ToLiteralExpression(this string str)
- {
- var syntaxToken = Literal(TriviaList(), @"""" + str + @"""", str, TriviaList());
- return LiteralExpression(SyntaxKind.StringLiteralExpression, syntaxToken);
- }
-
- public static SyntaxToken ToIdentifier(this string identifier)
- {
- identifier = identifier.TrimStart('@');
-
- if (Identifier.IsCSharpKeyword(identifier))
- {
- return VerbatimIdentifier(
- SyntaxTriviaList.Empty,
- identifier,
- identifier,
- SyntaxTriviaList.Empty);
- }
-
- return Identifier(SyntaxTriviaList.Empty, identifier, SyntaxTriviaList.Empty);
- }
-
- public static IdentifierNameSyntax ToIdentifierName(this string identifier)
- {
- return IdentifierName(identifier.ToIdentifier());
- }
-
- public static GenericNameSyntax ToGenericName(this string identifier)
- {
- return GenericName(identifier.ToIdentifier());
- }
-
- public static ExpressionSyntax ToHexLiteral(this int val)
- {
- ExpressionSyntax expr = CastExpression(PredefinedType(Token(SyntaxKind.IntKeyword)),
- LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal($"0x{val:X}", val)));
- if (val < 0)
- {
- expr = CheckedExpression(SyntaxKind.UncheckedExpression, expr);
- }
-
- return expr;
- }
- }
-}
diff --git a/src/Orleans.CodeGenerator/Utilities/SymbolDisplayFormatExtensions.cs b/src/Orleans.CodeGenerator/Utilities/SymbolDisplayFormatExtensions.cs
deleted file mode 100644
index ffe1fedca79..00000000000
--- a/src/Orleans.CodeGenerator/Utilities/SymbolDisplayFormatExtensions.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using Microsoft.CodeAnalysis;
-
-namespace Orleans.CodeGenerator.Utilities
-{
- internal static class SymbolDisplayFormatExtensions
- {
- public static SymbolDisplayFormat WithTypeQualificationStyle(this SymbolDisplayFormat format, SymbolDisplayTypeQualificationStyle style)
- {
- return new SymbolDisplayFormat(
- format.GlobalNamespaceStyle,
- style,
- format.GenericsOptions,
- format.MemberOptions,
- format.DelegateStyle,
- format.ExtensionMethodStyle,
- format.ParameterOptions,
- format.PropertyStyle,
- format.LocalOptions,
- format.KindOptions,
- format.MiscellaneousOptions);
- }
- }
-}
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator/Utilities/SymbolExtensions.cs b/src/Orleans.CodeGenerator/Utilities/SymbolExtensions.cs
deleted file mode 100644
index 217ecf9766e..00000000000
--- a/src/Orleans.CodeGenerator/Utilities/SymbolExtensions.cs
+++ /dev/null
@@ -1,233 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.CodeAnalysis;
-
-namespace Orleans.CodeGenerator.Utilities
-{
- internal static class SymbolExtensions
- {
- public static string GetNamespaceName(this INamespaceOrTypeSymbol type)
- {
- // global::A.B.C
- var result = new StringBuilder();
- Recurse(type, result);
- return result.ToString();
-
- void Recurse(INamespaceOrTypeSymbol symbol, StringBuilder sb)
- {
- var ns = symbol.ContainingNamespace;
- if (ns != null && !ns.IsGlobalNamespace)
- {
- Recurse(ns, sb);
- if (sb.Length > 0) sb.Append('.');
- sb.Append(ns.Name);
- }
- }
- }
-
- public static IEnumerable GetHierarchyTypeParameters(this INamedTypeSymbol type)
- {
- if (type.ContainingType != null)
- {
- foreach (var t in type.ContainingType.GetHierarchyTypeParameters()) yield return t;
- }
-
- foreach (var t in type.TypeParameters) yield return t;
- }
-
- public static IEnumerable GetHierarchyTypeArguments(this INamedTypeSymbol type)
- {
- if (type.ContainingType != null)
- {
- foreach (var t in type.ContainingType.GetHierarchyTypeArguments()) yield return t;
- }
-
- foreach (var t in type.TypeArguments) yield return t;
- }
-
- public static string GetGenericTypeSuffix(this INamedTypeSymbol type)
- {
- var numParams = type.GetHierarchyTypeParameters().Count();
- if (numParams == 0) return string.Empty;
- return '<' + new string(',', numParams - 1) + '>';
- }
-
- public static string GetSuitableClassName(this INamedTypeSymbol type)
- {
- if (type.TypeKind != TypeKind.Interface && type.TypeKind != TypeKind.Class && type.TypeKind != TypeKind.Struct)
- throw new NotSupportedException($"Type {type} has kind {type.TypeKind}, which is not supported.");
-
- if (type.IsImplicitlyDeclared)
- throw new NotSupportedException($"Type {type} is implicitly declared, which is not supported.");
-
- var index = type.MetadataName.IndexOf('`');
- var trimmed = index > 0 ? type.MetadataName.Substring(0, index) : type.MetadataName;
-
- var isInterface = type.TypeKind == TypeKind.Interface;
- if (isInterface) return GetClassNameFromInterfaceName(trimmed);
- return trimmed;
-
- string GetClassNameFromInterfaceName(string interfaceName)
- {
- if (interfaceName.StartsWith("i", StringComparison.OrdinalIgnoreCase))
- {
- return interfaceName.Substring(1);
- }
-
- return interfaceName;
- }
- }
-
- public static IEnumerable GetDeclaredTypes(this IAssemblySymbol reference)
- {
- foreach (var module in reference.Modules)
- {
- foreach (var type in GetDeclaredTypes(module.GlobalNamespace))
- {
- yield return type;
- }
- }
-
- IEnumerable GetDeclaredTypes(INamespaceOrTypeSymbol ns)
- {
- foreach (var member in ns.GetMembers())
- {
- switch (member)
- {
- case INamespaceSymbol nestedNamespace:
- foreach (var nested in GetDeclaredTypes(nestedNamespace)) yield return nested;
- break;
- case ITypeSymbol type:
- if (type is INamedTypeSymbol namedType) yield return namedType;
- foreach (var nested in GetDeclaredTypes(type)) yield return nested;
- break;
- }
- }
- }
- }
-
- public static bool HasInterface(this ITypeSymbol typeSymbol, INamedTypeSymbol interfaceTypeSymbol)
- {
- return typeSymbol.AllInterfaces.Contains(interfaceTypeSymbol);
- }
-
- public static bool HasBaseType(this ITypeSymbol typeSymbol, INamedTypeSymbol baseType)
- {
- if (baseType.Equals(typeSymbol.BaseType)) return true;
- if (typeSymbol.BaseType == null) return false;
- return typeSymbol.BaseType.HasBaseType(baseType);
- }
-
- public static bool HasAttribute(this ISymbol symbol, INamedTypeSymbol attributeType)
- {
- var attributes = symbol.GetAttributes();
- foreach (var attr in attributes)
- {
- if (attr.AttributeClass.Equals(attributeType)) return true;
- }
-
- return false;
- }
-
- public static bool GetAttribute(this ISymbol symbol, INamedTypeSymbol attributeType, out AttributeData attribute)
- {
- if (!symbol.GetAttributes(attributeType, out var attributes))
- {
- attribute = null;
- return false;
- }
-
- if (attributes.Length > 1) throw new InvalidOperationException($"Symbol {symbol} has {attributes.Length} attributes of type {attributeType}.");
-
- attribute = attributes[0];
- return true;
- }
-
- ///
- /// Gets all attributes which are assignable to the specified attribute type.
- ///
- public static bool GetAttributes(this ISymbol symbol, INamedTypeSymbol attributeType, out AttributeData[] attributes)
- {
- var temp = default(List);
- foreach (var attr in symbol.GetAttributes())
- {
- if (!attr.AttributeClass.Equals(attributeType) && !attr.AttributeClass.HasBaseType(attributeType)) continue;
-
- if (temp == null) temp = new List();
- temp.Add(attr);
- }
-
- attributes = temp?.ToArray();
- return attributes != null && attributes.Length > 0;
- }
-
- public static string GetValidIdentifier(this ITypeSymbol type)
- {
- switch (type)
- {
- case INamedTypeSymbol named when !named.IsGenericType: return $"{named.Name}";
- case INamedTypeSymbol named:
- return $"{named.Name}_{string.Join("_", named.TypeArguments.Select(GetValidIdentifier))}";
- case IArrayTypeSymbol array:
- return $"{GetValidIdentifier(array.ElementType)}_{array.Rank}";
- case IPointerTypeSymbol pointer:
- return $"{GetValidIdentifier(pointer.PointedAtType)}_ptr";
- case ITypeParameterSymbol parameter:
- return $"{parameter.Name}";
- default:
- throw new NotSupportedException($"Unable to format type of kind {type.GetType()} with name \"{type.Name}\"");
- }
- }
-
- public static IEnumerable GetAllMembers(this ITypeSymbol type) where TSymbol : ISymbol
- {
- foreach (var candidate in type.GetMembers())
- {
- if (candidate is TSymbol symbol) yield return symbol;
- }
-
- var baseType = type.BaseType;
- if (baseType != null)
- {
- foreach (var t in baseType.GetAllMembers()) yield return t;
- }
- }
-
- public static TSymbol Member(this ITypeSymbol type, string name, Func predicate = null) where TSymbol : class
- {
- var methods = type.GetMembers(name).OfType();
- if (predicate != null) methods = methods.Where(predicate);
-
- var results = methods.ToList();
-
- if (results.Count == 0)
- {
- throw new KeyNotFoundException(
- $"Type {type} does not have a member of kind {typeof(TSymbol)} named {name}{(predicate == null ? String.Empty : " matching the specified predicate.")}");
- }
-
- if (results.Count > 1)
- {
- throw new InvalidOperationException(
- $"Type {type} has multiple members of kind {typeof(TSymbol)} named {name}{(predicate == null ? String.Empty : " matching the specified predicate.")}");
- }
-
- return results[0];
- }
-
- public static IMethodSymbol Method(this ITypeSymbol type, string name, Func predicate = null) => type.Member(name, predicate);
-
- public static IMethodSymbol Method(this ITypeSymbol type, string name, params INamedTypeSymbol[] parameters) =>
- type.Member(name, m => m.Parameters.Select(p => p.Type).SequenceEqual(parameters));
-
- public static IPropertySymbol Property(this ITypeSymbol type, string name) => type.Member(name);
-
- public static INamedTypeSymbol WithoutTypeParameters(this INamedTypeSymbol type)
- {
- if (type.IsGenericType && !type.IsUnboundGenericType) return type.ConstructUnboundGenericType();
- return type;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator/Utilities/SymbolSyntaxExtensions.cs b/src/Orleans.CodeGenerator/Utilities/SymbolSyntaxExtensions.cs
deleted file mode 100644
index 59d44799f1b..00000000000
--- a/src/Orleans.CodeGenerator/Utilities/SymbolSyntaxExtensions.cs
+++ /dev/null
@@ -1,347 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Linq.Expressions;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-
-namespace Orleans.CodeGenerator.Utilities
-{
- ///
- /// Extensions for syntax types.
- ///
- internal static class SymbolSyntaxExtensions
- {
- public static string GetParsableReplacementName(this INamedTypeSymbol originalType, string replacementTypeName)
- {
- var t = originalType.WithoutTypeParameters();
- var ns = t.GetNamespaceName();
- if (!string.IsNullOrWhiteSpace(ns)) ns += '.';
-
- return ns + replacementTypeName + t.GetGenericTypeSuffix();
- }
-
- public static SyntaxKind ToSyntaxKind(this SpecialType specialType)
- {
- switch (specialType)
- {
- case SpecialType.System_Object:
- return SyntaxKind.ObjectKeyword;
- case SpecialType.System_Void:
- return SyntaxKind.VoidKeyword;
- case SpecialType.System_Boolean:
- return SyntaxKind.BoolKeyword;
- case SpecialType.System_Char:
- return SyntaxKind.CharKeyword;
- case SpecialType.System_SByte:
- return SyntaxKind.SByteKeyword;
- case SpecialType.System_Byte:
- return SyntaxKind.ByteKeyword;
- case SpecialType.System_Int16:
- return SyntaxKind.ShortKeyword;
- case SpecialType.System_UInt16:
- return SyntaxKind.UShortKeyword;
- case SpecialType.System_Int32:
- return SyntaxKind.IntKeyword;
- case SpecialType.System_UInt32:
- return SyntaxKind.UIntKeyword;
- case SpecialType.System_Int64:
- return SyntaxKind.LongKeyword;
- case SpecialType.System_UInt64:
- return SyntaxKind.ULongKeyword;
- case SpecialType.System_Decimal:
- return SyntaxKind.DecimalKeyword;
- case SpecialType.System_Single:
- return SyntaxKind.FloatKeyword;
- case SpecialType.System_Double:
- return SyntaxKind.DoubleKeyword;
- case SpecialType.System_String:
- return SyntaxKind.StringKeyword;
- default:
- return SyntaxKind.None;
- }
- }
-
- public static bool GetPredefinedType(INamedTypeSymbol type, out PredefinedTypeSyntax predefined)
- {
- var kind = type.SpecialType.ToSyntaxKind();
- if (kind == SyntaxKind.None)
- {
- predefined = null;
- return false;
- }
-
- predefined = PredefinedType(Token(kind));
- return true;
- }
-
- public static TypeSyntax ToTypeSyntax(this ITypeSymbol typeSymbol)
- {
- if (typeSymbol is INamedTypeSymbol named) return named.ToTypeSyntax();
- return ParseTypeName(typeSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat));
- }
-
- public static TypeSyntax ToTypeSyntax(this INamedTypeSymbol type, Func modifyFormat = null)
- {
- if (GetPredefinedType(type, out var predefined))
- {
- return predefined;
- }
-
- var format = SymbolDisplayFormat.FullyQualifiedFormat;
- if (modifyFormat != null) format = modifyFormat(format);
-
- return ParseTypeName(type.ToDisplayString(format));
- }
-
- public static NameSyntax ToNameSyntax(this INamedTypeSymbol type, bool includeNamespace = true)
- {
- var format = SymbolDisplayFormat.FullyQualifiedFormat;
- if (!includeNamespace)
- {
- format = format.WithTypeQualificationStyle(SymbolDisplayTypeQualificationStyle.NameAndContainingTypes);
- }
-
- return ParseName(type.ToDisplayString(format));
- }
-
- public static ParenthesizedExpressionSyntax GetBindingFlagsParenthesizedExpressionSyntax(SyntaxKind operationKind, params System.Reflection.BindingFlags[] bindingFlags)
- {
- if (bindingFlags.Length < 2)
- {
- throw new ArgumentOutOfRangeException(
- nameof(bindingFlags),
- $"Can't create parenthesized binary expression with {bindingFlags.Length} arguments");
- }
-
- var flags = IdentifierName("System").Member("Reflection").Member("BindingFlags");
- var bindingFlagsBinaryExpression = BinaryExpression(
- operationKind,
- flags.Member(bindingFlags[0].ToString()),
- flags.Member(bindingFlags[1].ToString()));
- for (var i = 2; i < bindingFlags.Length; i++)
- {
- bindingFlagsBinaryExpression = BinaryExpression(
- operationKind,
- bindingFlagsBinaryExpression,
- flags.Member(bindingFlags[i].ToString()));
- }
-
- return ParenthesizedExpression(bindingFlagsBinaryExpression);
- }
-
- public static MethodDeclarationSyntax GetDeclarationSyntax(this IMethodSymbol method)
- {
- if (!(method.ReturnType is INamedTypeSymbol returnType)) throw new InvalidOperationException($"Return type \"{method.ReturnType?.GetType()}\" for method {method} is not a named type.");
- var syntax =
- MethodDeclaration(ToTypeSyntax(returnType), method.Name.ToIdentifier())
- .WithParameterList(ParameterList().AddParameters(method.Parameters.Select(p => Parameter(p.Name.ToIdentifier()).WithType(p.Type.ToTypeSyntax())).ToArray()));
- if (method.IsGenericMethod)
- {
- syntax = syntax.WithTypeParameterList(TypeParameterList().AddParameters(method.GetTypeParameterListSyntax()));
-
- // Handle type constraints on type parameters.
- var typeParameters = method.TypeParameters;
- var typeParameterConstraints = new List();
- foreach (var arg in typeParameters)
- {
- typeParameterConstraints.AddRange(GetTypeParameterConstraints(arg));
- }
-
- if (typeParameterConstraints.Count > 0)
- {
- syntax = syntax.AddConstraintClauses(typeParameterConstraints.ToArray());
- }
- }
-
- syntax = syntax.WithModifiers(syntax.Modifiers.AddAccessibilityModifiers(method.DeclaredAccessibility));
-
- return syntax;
- }
-
- public static ArrayTypeSyntax GetArrayTypeSyntax(this TypeSyntax type)
- {
- return ArrayType(type, SingletonList(ArrayRankSpecifier(SingletonSeparatedList(OmittedArraySizeExpression()))));
- }
-
- public static ConstructorDeclarationSyntax GetConstructorDeclarationSyntax(this IMethodSymbol constructor, string typeName)
- {
- var syntax =
- ConstructorDeclaration(typeName.ToIdentifier())
- .WithParameterList(ParameterList().AddParameters(constructor.GetParameterListSyntax()));
-
- syntax.WithModifiers(syntax.Modifiers.AddAccessibilityModifiers(constructor.DeclaredAccessibility));
-
- return syntax;
- }
-
- public static SyntaxTokenList AddAccessibilityModifiers(this SyntaxTokenList syntax, Accessibility accessibility)
- {
- switch (accessibility)
- {
- case Accessibility.Public:
- syntax = With(syntax, SyntaxKind.PublicKeyword);
- break;
- case Accessibility.Private:
- syntax = With(syntax, SyntaxKind.PrivateKeyword);
- break;
- case Accessibility.Internal:
- syntax = With(syntax, SyntaxKind.InternalKeyword);
- break;
- case Accessibility.Protected:
- syntax = With(syntax, SyntaxKind.ProtectedKeyword);
- break;
- case Accessibility.ProtectedOrInternal:
- syntax = With(With(syntax, SyntaxKind.ProtectedKeyword), SyntaxKind.InternalKeyword);
- break;
- case Accessibility.ProtectedAndInternal:
- syntax = With(With(syntax, SyntaxKind.PrivateKeyword), SyntaxKind.ProtectedKeyword);
- break;
- }
-
- SyntaxTokenList With(SyntaxTokenList s, SyntaxKind keyword)
- {
- foreach (var t in s)
- {
- if (t.IsKind(keyword)) return s;
- }
-
- return s.Add(Token(keyword));
- }
-
- return syntax;
- }
-
- public static ParameterSyntax[] GetParameterListSyntax(this IMethodSymbol method)
- {
- return
- method.Parameters
- .Select(
- (parameter, parameterIndex) =>
- Parameter(parameter.Name.ToIdentifier())
- .WithType(parameter.Type.ToTypeSyntax()))
- .ToArray();
- }
-
- public static TypeParameterSyntax[] GetTypeParameterListSyntax(this IMethodSymbol method)
- {
- return method.TypeParameters
- .Select(parameter => TypeParameter(parameter.Name))
- .ToArray();
- }
-
- public static TypeParameterConstraintClauseSyntax[] GetTypeConstraintSyntax(this INamedTypeSymbol type)
- {
- if (type.IsGenericType)
- {
- var constraints = new List();
- foreach (var genericParameter in type.GetHierarchyTypeParameters())
- {
- constraints.AddRange(GetTypeParameterConstraints(genericParameter));
- }
-
- return constraints.ToArray();
- }
-
- return new TypeParameterConstraintClauseSyntax[0];
- }
-
- private static TypeParameterConstraintClauseSyntax[] GetTypeParameterConstraints(ITypeParameterSymbol genericParameter)
- {
- var results = new List();
- var parameterConstraints = new List();
-
- // The "class" or "struct" constraints must come first.
- if (genericParameter.HasReferenceTypeConstraint)
- {
- parameterConstraints.Add(ClassOrStructConstraint(SyntaxKind.ClassConstraint));
- }
- else if (genericParameter.HasValueTypeConstraint)
- {
- parameterConstraints.Add(ClassOrStructConstraint(SyntaxKind.StructConstraint));
- }
-
- // Follow with the base class or interface constraints.
- foreach (var genericType in genericParameter.ConstraintTypes)
- {
- // If the "struct" constraint was specified, skip the corresponding "ValueType" constraint.
- if (genericType.SpecialType == SpecialType.System_ValueType)
- {
- continue;
- }
-
- parameterConstraints.Add(TypeConstraint(genericType.ToTypeSyntax()));
- }
-
- // The "new()" constraint must be the last constraint in the sequence.
- if (genericParameter.HasConstructorConstraint
- && !genericParameter.HasValueTypeConstraint)
- {
- parameterConstraints.Add(ConstructorConstraint());
- }
-
- if (parameterConstraints.Count > 0)
- {
- results.Add(
- TypeParameterConstraintClause(genericParameter.Name)
- .AddConstraints(parameterConstraints.ToArray()));
- }
-
- return results.ToArray();
- }
-
- public static MemberAccessExpressionSyntax Member(this ExpressionSyntax instance, string member)
- {
- return instance.Member(member.ToIdentifierName());
- }
-
- public static MemberAccessExpressionSyntax Member(
- this ExpressionSyntax instance,
- string member,
- params INamedTypeSymbol[] genericTypes)
- {
- return
- instance.Member(
- member.ToGenericName()
- .AddTypeArgumentListArguments(genericTypes.Select(_ => _.ToTypeSyntax()).ToArray()));
- }
-
- public static MemberAccessExpressionSyntax Member(
- this ExpressionSyntax instance,
- Expression> member,
- params INamedTypeSymbol[] genericTypes)
- {
- switch (member.Body)
- {
- case MethodCallExpression methodCall:
- if (genericTypes != null && genericTypes.Length > 0)
- {
- return instance.Member(methodCall.Method.Name, genericTypes);
- }
-
- return instance.Member(methodCall.Method.Name.ToIdentifierName());
- case MemberExpression memberAccess:
- if (genericTypes != null && genericTypes.Length > 0)
- {
- return instance.Member(memberAccess.Member.Name, genericTypes);
- }
-
- return instance.Member(memberAccess.Member.Name.ToIdentifierName());
- }
-
- throw new ArgumentException("Expression type unsupported.");
- }
-
- public static MemberAccessExpressionSyntax Member(this ExpressionSyntax instance, IdentifierNameSyntax member)
- {
- return MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, instance, member);
- }
-
- public static MemberAccessExpressionSyntax Member(this ExpressionSyntax instance, GenericNameSyntax member)
- {
- return MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, instance, member);
- }
- }
-}
\ No newline at end of file
diff --git a/src/Orleans.CodeGenerator/WellKnownTypes.cs b/src/Orleans.CodeGenerator/WellKnownTypes.cs
deleted file mode 100644
index 4e553f507aa..00000000000
--- a/src/Orleans.CodeGenerator/WellKnownTypes.cs
+++ /dev/null
@@ -1,224 +0,0 @@
-using System;
-using System.Diagnostics.CodeAnalysis;
-using Microsoft.CodeAnalysis;
-
-namespace Orleans.CodeGenerator
-{
- [SuppressMessage("ReSharper", "InconsistentNaming", Justification = "These property names reflect type names.")]
- internal class WellKnownTypes
- {
- public static WellKnownTypes FromCompilation(Compilation compilation)
- {
- return new WellKnownTypes
- {
- AbstractionsAssembly = Type("Orleans.IGrain").ContainingAssembly,
- Action_2 = Type("System.Action`2"),
- AlwaysInterleaveAttribute = Type("Orleans.Concurrency.AlwaysInterleaveAttribute"),
- ArgumentNullException = Type("System.ArgumentNullException"),
- CopierMethodAttribute = Type("Orleans.CodeGeneration.CopierMethodAttribute"),
- DeserializerMethodAttribute = Type("Orleans.CodeGeneration.DeserializerMethodAttribute"),
- Delegate = compilation.GetSpecialType(SpecialType.System_Delegate),
- Exception = Type("System.Exception"),
- ExcludeFromCodeCoverageAttribute = Type("System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute"),
- FormatterServices = Type("System.Runtime.Serialization.FormatterServices"),
- FieldInfo = Type("System.Reflection.FieldInfo"),
- Func_2 = Type("System.Func`2"),
- GeneratedCodeAttribute = Type("System.CodeDom.Compiler.GeneratedCodeAttribute"),
- Grain = Type("Orleans.Grain"),
- GrainFactoryBase = Type("Orleans.CodeGeneration.GrainFactoryBase"),
- GrainOfT = Type("Orleans.Grain`1"),
- GrainReference = Type("Orleans.Runtime.GrainReference"),
- GrainReferenceAttribute = Type("Orleans.CodeGeneration.GrainReferenceAttribute"),
- IAddressable = Type("Orleans.Runtime.IAddressable"),
- ICopyContext = Type("Orleans.Serialization.ICopyContext"),
- IDeserializationContext = Type("Orleans.Serialization.IDeserializationContext"),
- IFieldUtils = Type("Orleans.Serialization.IFieldUtils"),
- IGrain = Type("Orleans.IGrain"),
- IGrainExtension = Type("Orleans.Runtime.IGrainExtension"),
- IGrainExtensionMethodInvoker = Type("Orleans.CodeGeneration.IGrainExtensionMethodInvoker"),
- IGrainMethodInvoker = Type("Orleans.CodeGeneration.IGrainMethodInvoker"),
- IGrainObserver = Type("Orleans.IGrainObserver"),
- IGrainWithGuidCompoundKey = Type("Orleans.IGrainWithGuidCompoundKey"),
- IGrainWithGuidKey = Type("Orleans.IGrainWithGuidKey"),
- IGrainWithIntegerCompoundKey = Type("Orleans.IGrainWithIntegerCompoundKey"),
- IGrainWithIntegerKey = Type("Orleans.IGrainWithIntegerKey"),
- IGrainWithStringKey = Type("Orleans.IGrainWithStringKey"),
- Immutable_1 = Type("Orleans.Concurrency.Immutable`1"),
- ImmutableAttribute = Type("Orleans.Concurrency.ImmutableAttribute"),
- Int32 = compilation.GetSpecialType(SpecialType.System_Int32),
- IntPtr = compilation.GetSpecialType(SpecialType.System_IntPtr),
- InvokeMethodOptions = Type("Orleans.CodeGeneration.InvokeMethodOptions"),
- InvokeMethodRequest = Type("Orleans.CodeGeneration.InvokeMethodRequest"),
- IOnDeserialized = Type("Orleans.Serialization.IOnDeserialized"),
- ISerializationContext = Type("Orleans.Serialization.ISerializationContext"),
- ISystemTarget = Type("Orleans.ISystemTarget"),
- MarshalByRefObject = Type("System.MarshalByRefObject"),
- MethodInvokerAttribute = Type("Orleans.CodeGeneration.MethodInvokerAttribute"),
- NonSerializedAttribute = Type("System.NonSerializedAttribute"),
- NotImplementedException = Type("System.NotImplementedException"),
- Object = compilation.GetSpecialType(SpecialType.System_Object),
- ObsoleteAttribute = Type("System.ObsoleteAttribute"),
- OneWayAttribute = Type("Orleans.Concurrency.OneWayAttribute"),
- ReadOnlyAttribute = Type("Orleans.Concurrency.ReadOnlyAttribute"),
- ReentrantAttribute = Type("Orleans.Concurrency.ReentrantAttribute"),
- SerializableAttribute = Type("System.SerializableAttribute"),
- SerializerAttribute = Type("Orleans.CodeGeneration.SerializerAttribute"),
- SerializerMethodAttribute = Type("Orleans.CodeGeneration.SerializerMethodAttribute"),
- StatelessWorkerAttribute = Type("Orleans.Concurrency.StatelessWorkerAttribute"),
- SerializerFeature = Type("Orleans.Serialization.SerializerFeature"),
- String = compilation.GetSpecialType(SpecialType.System_String),
- Task = Type("System.Threading.Tasks.Task"),
- Task_1 = Type("System.Threading.Tasks.Task`1"),
- TimeSpan = Type("System.TimeSpan"),
- IPAddress = Type("System.Net.IPAddress"),
- IPEndPoint = Type("System.Net.IPEndPoint"),
- SiloAddress = Type("Orleans.Runtime.SiloAddress"),
- GrainId = Type("Orleans.Runtime.GrainId"),
- GrainInterfaceMetadata = Type("Orleans.Metadata.GrainInterfaceMetadata"),
- GrainClassMetadata = Type("Orleans.Metadata.GrainClassMetadata"),
- IFeaturePopulator_1 = Type("Orleans.Metadata.IFeaturePopulator`1"),
- FeaturePopulatorAttribute = Type("Orleans.Metadata.FeaturePopulatorAttribute"),
- GrainClassFeature = Type("Orleans.Metadata.GrainClassFeature"),
- GrainInterfaceFeature = Type("Orleans.Metadata.GrainInterfaceFeature"),
- ActivationId = Type("Orleans.Runtime.ActivationId"),
- ActivationAddress = Type("Orleans.Runtime.ActivationAddress"),
- CorrelationId = OptionalType("Orleans.Runtime.CorrelationId"),
- CancellationToken = Type("System.Threading.CancellationToken"),
- TransactionAttribute = Type("Orleans.TransactionAttribute"),
- TransactionOption = Type("Orleans.TransactionOption"),
- Type = Type("System.Type"),
- TypeCodeOverrideAttribute = Type("Orleans.CodeGeneration.TypeCodeOverrideAttribute"),
- MethodIdAttribute = Type("Orleans.CodeGeneration.MethodIdAttribute"),
- UInt16 = compilation.GetSpecialType(SpecialType.System_UInt16),
- UIntPtr = compilation.GetSpecialType(SpecialType.System_UIntPtr),
- UnorderedAttribute = Type("Orleans.Concurrency.UnorderedAttribute"),
- ValueTypeSetter_2 = Type("Orleans.Serialization.ValueTypeSetter`2"),
- VersionAttribute = Type("Orleans.CodeGeneration.VersionAttribute"),
- Void = compilation.GetSpecialType(SpecialType.System_Void),
- GenericMethodInvoker = OptionalType("Orleans.CodeGeneration.GenericMethodInvoker"),
- KnownAssemblyAttribute = Type("Orleans.CodeGeneration.KnownAssemblyAttribute"),
- KnownBaseTypeAttribute = Type("Orleans.CodeGeneration.KnownBaseTypeAttribute"),
- ConsiderForCodeGenerationAttribute = Type("Orleans.CodeGeneration.ConsiderForCodeGenerationAttribute"),
- };
-
- INamedTypeSymbol Type(string type)
- {
- var result = compilation.GetTypeByMetadataName(type);
- if (result == null) throw new InvalidOperationException($"Unable to find type with metadata name \"{type}\".");
- return result;
- }
-
- OptionalType OptionalType(string type)
- {
- var result = compilation.GetTypeByMetadataName(type);
- if (result == null) return None.Instance;
- return new Some(result);
- }
- }
-
- public IAssemblySymbol AbstractionsAssembly { get; private set; }
- public INamedTypeSymbol TimeSpan { get; private set; }
- public INamedTypeSymbol GrainClassMetadata { get; private set; }
- public INamedTypeSymbol GrainInterfaceMetadata { get; private set; }
- public INamedTypeSymbol IPAddress { get; private set; }
- public INamedTypeSymbol IPEndPoint { get; private set; }
- public INamedTypeSymbol SiloAddress { get; private set; }
- public INamedTypeSymbol GrainId { get; private set; }
- public INamedTypeSymbol IFeaturePopulator_1 { get; private set; }
- public INamedTypeSymbol FeaturePopulatorAttribute { get; private set; }
- public INamedTypeSymbol GrainInterfaceFeature { get; private set; }
- public INamedTypeSymbol ActivationId { get; private set; }
- public INamedTypeSymbol ActivationAddress { get; private set; }
- public OptionalType CorrelationId { get; private set; }
- public INamedTypeSymbol CancellationToken { get; private set; }
- public INamedTypeSymbol Action_2 { get; private set; }
- public INamedTypeSymbol AlwaysInterleaveAttribute { get; private set; }
- public INamedTypeSymbol ArgumentNullException { get; private set; }
- public INamedTypeSymbol CopierMethodAttribute { get; private set; }
- public INamedTypeSymbol Delegate { get; private set; }
- public INamedTypeSymbol DeserializerMethodAttribute { get; private set; }
- public INamedTypeSymbol Exception { get; private set; }
- public INamedTypeSymbol ExcludeFromCodeCoverageAttribute { get; private set; }
- public INamedTypeSymbol FormatterServices { get; private set; }
- public INamedTypeSymbol FieldInfo { get; private set; }
- public INamedTypeSymbol Func_2 { get; private set; }
- public INamedTypeSymbol GeneratedCodeAttribute { get; private set; }
- public OptionalType GenericMethodInvoker { get; private set; }
- public INamedTypeSymbol Grain { get; private set; }
- public INamedTypeSymbol GrainFactoryBase { get; private set; }
- public INamedTypeSymbol GrainOfT { get; private set; }
- public INamedTypeSymbol GrainReference { get; private set; }
- public INamedTypeSymbol GrainReferenceAttribute { get; private set; }
- public INamedTypeSymbol IAddressable { get; private set; }
- public INamedTypeSymbol ICopyContext { get; private set; }
- public INamedTypeSymbol IDeserializationContext { get; private set; }
- public INamedTypeSymbol IFieldUtils { get; private set; }
- public INamedTypeSymbol IGrain { get; private set; }
- public INamedTypeSymbol IGrainExtension { get; private set; }
- public INamedTypeSymbol IGrainExtensionMethodInvoker { get; private set; }
- public INamedTypeSymbol GrainClassFeature { get; private set; }
- public INamedTypeSymbol SerializerFeature { get; private set; }
- public INamedTypeSymbol IGrainMethodInvoker { get; private set; }
- public INamedTypeSymbol IGrainObserver { get; private set; }
- public INamedTypeSymbol IGrainWithGuidCompoundKey { get; private set; }
- public INamedTypeSymbol IGrainWithGuidKey { get; private set; }
- public INamedTypeSymbol IGrainWithIntegerCompoundKey { get; private set; }
- public INamedTypeSymbol IGrainWithIntegerKey { get; private set; }
- public INamedTypeSymbol IGrainWithStringKey { get; private set; }
- public INamedTypeSymbol Immutable_1 { get; private set; }
- public INamedTypeSymbol ImmutableAttribute { get; private set; }
- public INamedTypeSymbol Int32 { get; private set; }
- public INamedTypeSymbol IntPtr { get; private set; }
- public INamedTypeSymbol InvokeMethodOptions { get; private set; }
- public INamedTypeSymbol InvokeMethodRequest { get; private set; }
- public INamedTypeSymbol IOnDeserialized { get; private set; }
- public INamedTypeSymbol ISerializationContext { get; private set; }
- public INamedTypeSymbol ISystemTarget { get; private set; }
- public INamedTypeSymbol MarshalByRefObject { get; private set; }
- public INamedTypeSymbol MethodInvokerAttribute { get; private set; }
- public INamedTypeSymbol NonSerializedAttribute { get; private set; }
- public INamedTypeSymbol NotImplementedException { get; private set; }
- public INamedTypeSymbol Object { get; private set; }
- public INamedTypeSymbol ObsoleteAttribute { get; private set; }
- public INamedTypeSymbol OneWayAttribute { get; private set; }
- public INamedTypeSymbol ReadOnlyAttribute { get; private set; }
- public INamedTypeSymbol ReentrantAttribute { get; private set; }
- public INamedTypeSymbol SerializableAttribute { get; private set; }
- public INamedTypeSymbol SerializerAttribute { get; private set; }
- public INamedTypeSymbol SerializerMethodAttribute { get; private set; }
- public INamedTypeSymbol StatelessWorkerAttribute { get; private set; }
- public INamedTypeSymbol String { get; private set; }
- public INamedTypeSymbol Task { get; private set; }
- public INamedTypeSymbol Task_1 { get; private set; }
- public INamedTypeSymbol TransactionAttribute { get; private set; }
- public INamedTypeSymbol TransactionOption { get; private set; }
- public INamedTypeSymbol Type { get; private set; }
- public INamedTypeSymbol TypeCodeOverrideAttribute { get; private set; }
- public INamedTypeSymbol MethodIdAttribute { get; private set; }
- public INamedTypeSymbol UInt16 { get; private set; }
- public INamedTypeSymbol UIntPtr { get; private set; }
- public INamedTypeSymbol UnorderedAttribute { get; private set; }
- public INamedTypeSymbol ValueTypeSetter_2 { get; private set; }
- public INamedTypeSymbol VersionAttribute { get; private set; }
- public INamedTypeSymbol Void { get; private set; }
- public INamedTypeSymbol KnownAssemblyAttribute { get; private set; }
- public INamedTypeSymbol KnownBaseTypeAttribute { get; private set; }
- public INamedTypeSymbol ConsiderForCodeGenerationAttribute { get; private set; }
- public class OptionalType { }
-
- public class None : OptionalType
- {
- public static None Instance { get; } = new None();
- }
-
- public class Some : OptionalType
- {
- public Some(INamedTypeSymbol value)
- {
- Value = value;
- }
-
- public INamedTypeSymbol Value { get; }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Orleans.Core.Abstractions/CodeGeneration/KnownAssemblyAttribute.cs b/src/Orleans.Core.Abstractions/CodeGeneration/KnownAssemblyAttribute.cs
index 8c4821852a8..574fe12ec95 100644
--- a/src/Orleans.Core.Abstractions/CodeGeneration/KnownAssemblyAttribute.cs
+++ b/src/Orleans.Core.Abstractions/CodeGeneration/KnownAssemblyAttribute.cs
@@ -17,10 +17,17 @@ public KnownAssemblyAttribute(Type type)
this.Assembly = type.GetTypeInfo().Assembly;
}
+ /// Initializes a new instance of .
+ /// The target assembly name.
+ public KnownAssemblyAttribute(string assemblyName)
+ {
+ this.Assembly = Assembly.Load(new AssemblyName(assemblyName));
+ }
+
///
/// Gets or sets the assembly to include in code generation.
///
- public Assembly Assembly { get; }
+ public Assembly Assembly { get; set; }
///
/// Gets or sets a value indicating whether or not to assume that all types in the specified assembly are
diff --git a/src/Orleans.Core.Abstractions/Orleans.Core.Abstractions.csproj b/src/Orleans.Core.Abstractions/Orleans.Core.Abstractions.csproj
index 4654f44ebdd..c228a9bd036 100644
--- a/src/Orleans.Core.Abstractions/Orleans.Core.Abstractions.csproj
+++ b/src/Orleans.Core.Abstractions/Orleans.Core.Abstractions.csproj
@@ -9,7 +9,7 @@
Orleans.Core.Abstractions
Orleans
- netstandard2.0
+ net462
diff --git a/src/Orleans.Core.Abstractions/Serialization/SerializerFeature.cs b/src/Orleans.Core.Abstractions/Serialization/SerializerFeature.cs
index 009dc3f075f..d419069eab8 100644
--- a/src/Orleans.Core.Abstractions/Serialization/SerializerFeature.cs
+++ b/src/Orleans.Core.Abstractions/Serialization/SerializerFeature.cs
@@ -31,11 +31,13 @@ public class SerializerFeature
public IList KnownTypes { get; } = new List();
///
- /// Adds a serializer type.
+ /// Adds a serializer type
///
- public void AddSerializerType(Type targetType, Type serializerType, bool overrideExisting = true)
+ ///
+ ///
+ public void AddSerializerType(Type targetType, Type serializerType)
{
- this.SerializerTypes.Add(new SerializerTypeMetadata(targetType, serializerType, overrideExisting));
+ this.SerializerTypes.Add(new SerializerTypeMetadata(targetType, serializerType));
}
///
@@ -55,11 +57,10 @@ public void AddKnownType(string fullyQualifiedTypeName, string typeKey)
[DebuggerDisplay("Serializer: {" + nameof(Serializer) + "}, Target: {"+ nameof(Target) + "}")]
public class SerializerTypeMetadata
{
- public SerializerTypeMetadata(Type target, Type serializer, bool overrideExisting = true)
+ public SerializerTypeMetadata(Type target, Type serializer)
{
this.Serializer = serializer;
this.Target = target;
- this.OverrideExisting = overrideExisting;
}
///
@@ -71,11 +72,6 @@ public SerializerTypeMetadata(Type target, Type serializer, bool overrideExistin
/// Gets the target type.
///
public Type Target { get; }
-
- ///
- /// Whether or not to override an existing registration for the provided .
- ///
- public bool OverrideExisting { get; }
}
///
@@ -84,10 +80,9 @@ public SerializerTypeMetadata(Type target, Type serializer, bool overrideExistin
[DebuggerDisplay("Target: {" + nameof(Target) + "}")]
public class SerializerDelegateMetadata
{
- public SerializerDelegateMetadata(Type target, DeepCopier deepCopier, Serializer serializer, Deserializer deserializer, bool overrideExisting = true)
+ public SerializerDelegateMetadata(Type target, DeepCopier deepCopier, Serializer serializer, Deserializer deserializer)
{
this.Target = target;
- this.OverrideExisting = overrideExisting;
this.Delegates = new SerializerMethods(deepCopier, serializer, deserializer);
}
@@ -96,11 +91,6 @@ public SerializerDelegateMetadata(Type target, DeepCopier deepCopier, Serializer
///
public Type Target { get; }
- ///
- /// Whether or not to override entries which
- ///
- public bool OverrideExisting { get; }
-
///
/// Gets the serialization delegates.
///
diff --git a/src/Orleans.Core.Abstractions/Transactions/TransactionAttribute.cs b/src/Orleans.Core.Abstractions/Transactions/TransactionAttribute.cs
index 3a8e7290cd0..ccfe9e66219 100644
--- a/src/Orleans.Core.Abstractions/Transactions/TransactionAttribute.cs
+++ b/src/Orleans.Core.Abstractions/Transactions/TransactionAttribute.cs
@@ -20,7 +20,7 @@ public TransactionAttribute(TransactionOptionAlias alias)
ReadOnly = false;
}
- public TransactionOption Requirement { get; }
+ public TransactionOption Requirement { get; set; }
public bool ReadOnly { get; set; }
}
diff --git a/src/Orleans.Core/CodeGeneration/GrainInterfaceUtils.cs b/src/Orleans.Core/CodeGeneration/GrainInterfaceUtils.cs
index 061c50d8be4..4df2965f9e8 100644
--- a/src/Orleans.Core/CodeGeneration/GrainInterfaceUtils.cs
+++ b/src/Orleans.Core/CodeGeneration/GrainInterfaceUtils.cs
@@ -160,12 +160,6 @@ public static int ComputeMethodId(MethodInfo methodInfo)
var attr = methodInfo.GetCustomAttribute(true);
if (attr != null) return attr.MethodId;
- var result = FormatMethodForIdComputation(methodInfo);
- return Utils.CalculateIdHash(result);
- }
-
- internal static string FormatMethodForIdComputation(MethodInfo methodInfo)
- {
var strMethodId = new StringBuilder(methodInfo.Name);
if (methodInfo.IsGenericMethodDefinition)
@@ -201,10 +195,8 @@ internal static string FormatMethodForIdComputation(MethodInfo methodInfo)
bFirstTime = false;
}
-
strMethodId.Append(')');
- var result = strMethodId.ToString();
- return result;
+ return Utils.CalculateIdHash(strMethodId.ToString());
}
public static int GetGrainInterfaceId(Type grainInterface)
diff --git a/src/Orleans.Core/Orleans.Core.csproj b/src/Orleans.Core/Orleans.Core.csproj
index f95aab135d6..160afa6ac20 100644
--- a/src/Orleans.Core/Orleans.Core.csproj
+++ b/src/Orleans.Core/Orleans.Core.csproj
@@ -8,7 +8,7 @@
Orleans.Core
Orleans
- true
+ true
diff --git a/src/Orleans.Core/Properties/AssemblyInfo.cs b/src/Orleans.Core/Properties/AssemblyInfo.cs
index 94d5f3a1f3d..3287fae157d 100644
--- a/src/Orleans.Core/Properties/AssemblyInfo.cs
+++ b/src/Orleans.Core/Properties/AssemblyInfo.cs
@@ -38,7 +38,6 @@
[assembly: InternalsVisibleTo("TestExtensions")]
[assembly: InternalsVisibleTo("TestInternalGrainInterfaces")]
[assembly: InternalsVisibleTo("TestInternalGrains")]
-[assembly: InternalsVisibleTo("CodeGenerator.Tests")]
// Legacy provider support
[assembly: InternalsVisibleTo("Orleans.Core.Legacy")]
diff --git a/src/Orleans.Core/Serialization/SerializationManager.cs b/src/Orleans.Core/Serialization/SerializationManager.cs
index d3d7f83ccf8..555d17d582f 100644
--- a/src/Orleans.Core/Serialization/SerializationManager.cs
+++ b/src/Orleans.Core/Serialization/SerializationManager.cs
@@ -139,17 +139,12 @@ private void RegisterSerializers(SerializerFeature serializerFeature)
foreach (var serializer in serializerFeature.SerializerDelegates)
{
- this.Register(
- serializer.Target,
- serializer.Delegates.DeepCopy,
- serializer.Delegates.Serialize,
- serializer.Delegates.Deserialize,
- serializer.OverrideExisting);
+ this.Register(serializer.Target, serializer.Delegates.DeepCopy, serializer.Delegates.Serialize, serializer.Delegates.Deserialize);
}
foreach (var serializer in serializerFeature.SerializerTypes)
{
- this.Register(serializer.Target, serializer.Serializer, serializer.OverrideExisting);
+ this.Register(serializer.Target, serializer.Serializer);
}
foreach (var knownType in serializerFeature.KnownTypes)
@@ -337,8 +332,7 @@ private void Register(Type t, string typeKey = null)
///
/// The type serialized by the provided serializer type.
/// The type containing serialization methods for .
- /// Whether or not to override existing registrations for the provided .
- private void Register(Type type, Type serializerType, bool overrideExisting = true)
+ private void Register(Type type, Type serializerType)
{
GetSerializationMethods(serializerType, out var copier, out var serializer, out var deserializer);
@@ -390,7 +384,7 @@ object DeserializeGeneric(Type expected, IDeserializationContext context)
copier != null ? DeepCopyGeneric : default(DeepCopier),
serializer != null ? SerializeGeneric : default(Serializer),
deserializer != null ? DeserializeGeneric : default(Deserializer),
- overrideExisting);
+ true);
}
else
{
@@ -400,7 +394,7 @@ object DeserializeGeneric(Type expected, IDeserializationContext context)
CreateDelegate(copier, serializerInstance),
CreateDelegate(serializer, serializerInstance),
CreateDelegate(deserializer, serializerInstance),
- overrideExisting);
+ true);
}
}
catch (ArgumentException)
diff --git a/src/Orleans.Core/Serialization/SerializerFeatureExtensions.cs b/src/Orleans.Core/Serialization/SerializerFeatureExtensions.cs
index ed257cc74ae..1331dfc3f35 100644
--- a/src/Orleans.Core/Serialization/SerializerFeatureExtensions.cs
+++ b/src/Orleans.Core/Serialization/SerializerFeatureExtensions.cs
@@ -23,10 +23,9 @@ public static void AddKnownType(this SerializerFeature serializerFeature, Type t
/// The copy delegate.
/// The serializer delegate.
/// The deserializer delegate.
- /// Whether or not to override other registrations.
- public static void AddSerializerDelegates(this SerializerFeature serializerFeature, Type type, DeepCopier copier, Serializer serializer, Deserializer deserializer, bool overrideExisting = true)
+ public static void AddSerializerDelegates(this SerializerFeature serializerFeature, Type type, DeepCopier copier, Serializer serializer, Deserializer deserializer)
{
- serializerFeature.SerializerDelegates.Add(new SerializerDelegateMetadata(type, copier, serializer, deserializer, overrideExisting));
+ serializerFeature.SerializerDelegates.Add(new SerializerDelegateMetadata(type, copier, serializer, deserializer));
}
}
}
\ No newline at end of file
diff --git a/src/Orleans.PowerShell/Orleans.PowerShell.csproj b/src/Orleans.PowerShell/Orleans.PowerShell.csproj
index 106ccc98216..a29ec8718e4 100644
--- a/src/Orleans.PowerShell/Orleans.PowerShell.csproj
+++ b/src/Orleans.PowerShell/Orleans.PowerShell.csproj
@@ -8,7 +8,7 @@
- net461
+ net462
Orleans.PowerShell
OrleansPSUtils
true
diff --git a/src/OrleansCounterControl/OrleansCounterControl.csproj b/src/OrleansCounterControl/OrleansCounterControl.csproj
index ef41c995b5f..77dc8392a7d 100644
--- a/src/OrleansCounterControl/OrleansCounterControl.csproj
+++ b/src/OrleansCounterControl/OrleansCounterControl.csproj
@@ -6,14 +6,14 @@
- net461
+ net462
Exe
Orleans.Counter.Control
OrleansCounterControl
app.manifest
-
+
win
diff --git a/src/OrleansManager/OrleansManager.csproj b/src/OrleansManager/OrleansManager.csproj
index 8affecab113..72278e20d5c 100644
--- a/src/OrleansManager/OrleansManager.csproj
+++ b/src/OrleansManager/OrleansManager.csproj
@@ -6,7 +6,7 @@
- net461
+ net462
Exe
win
OrleansManager
diff --git a/src/Serializers/Orleans.Serialization.Protobuf/Orleans.Serialization.Protobuf.csproj b/src/Serializers/Orleans.Serialization.Protobuf/Orleans.Serialization.Protobuf.csproj
index 538c88045d5..c63d28a7a9c 100644
--- a/src/Serializers/Orleans.Serialization.Protobuf/Orleans.Serialization.Protobuf.csproj
+++ b/src/Serializers/Orleans.Serialization.Protobuf/Orleans.Serialization.Protobuf.csproj
@@ -13,6 +13,7 @@
+
diff --git a/src/TelemetryConsumers/Orleans.TelemetryConsumers.Counters/Orleans.TelemetryConsumers.Counters.csproj b/src/TelemetryConsumers/Orleans.TelemetryConsumers.Counters/Orleans.TelemetryConsumers.Counters.csproj
index 7d3525621c9..419764cbda8 100644
--- a/src/TelemetryConsumers/Orleans.TelemetryConsumers.Counters/Orleans.TelemetryConsumers.Counters.csproj
+++ b/src/TelemetryConsumers/Orleans.TelemetryConsumers.Counters/Orleans.TelemetryConsumers.Counters.csproj
@@ -6,7 +6,7 @@
- netstandard2.0
+ net462
library
Orleans.TelemetryConsumers.Counters
OrleansTelemetryConsumers.Counters
diff --git a/src/TelemetryConsumers/Orleans.TelemetryConsumers.NewRelic/Orleans.TelemetryConsumers.NewRelic.csproj b/src/TelemetryConsumers/Orleans.TelemetryConsumers.NewRelic/Orleans.TelemetryConsumers.NewRelic.csproj
index e4d97bc440a..4b2ad21fee3 100644
--- a/src/TelemetryConsumers/Orleans.TelemetryConsumers.NewRelic/Orleans.TelemetryConsumers.NewRelic.csproj
+++ b/src/TelemetryConsumers/Orleans.TelemetryConsumers.NewRelic/Orleans.TelemetryConsumers.NewRelic.csproj
@@ -7,7 +7,7 @@
- net461
+ net462
Orleans.TelemetryConsumers.NewRelic
Orleans.TelemetryConsumers.NewRelic
diff --git a/test/Benchmarks/Benchmarks.csproj b/test/Benchmarks/Benchmarks.csproj
index d8c9e1e0ff6..f66ab5ae443 100644
--- a/test/Benchmarks/Benchmarks.csproj
+++ b/test/Benchmarks/Benchmarks.csproj
@@ -2,7 +2,7 @@
Benchmarks
Benchmarks
- netcoreapp2.0;net461
+ net462
Exe
pdbonly
true
diff --git a/test/CodeGeneration/CodeGenerator.Tests/CodeGenerator.Tests.csproj b/test/CodeGeneration/CodeGenerator.Tests/CodeGenerator.Tests.csproj
index 22b71d0c27f..fed22b9cfe0 100644
--- a/test/CodeGeneration/CodeGenerator.Tests/CodeGenerator.Tests.csproj
+++ b/test/CodeGeneration/CodeGenerator.Tests/CodeGenerator.Tests.csproj
@@ -1,7 +1,7 @@
- netcoreapp2.1
+ net462
false
diff --git a/test/CodeGeneration/CodeGenerator.Tests/RoslynTypeNameFormatterTests.cs b/test/CodeGeneration/CodeGenerator.Tests/RoslynTypeNameFormatterTests.cs
index 63edc3f18d8..69c84870401 100644
--- a/test/CodeGeneration/CodeGenerator.Tests/RoslynTypeNameFormatterTests.cs
+++ b/test/CodeGeneration/CodeGenerator.Tests/RoslynTypeNameFormatterTests.cs
@@ -91,7 +91,7 @@ IEnumerable GetGlobalReferences()
var assemblyPath = Path.GetDirectoryName(typeof(object).Assembly.Location);
return new List
{
- MetadataReference.CreateFromFile(Path.Combine(assemblyPath, "netstandard.dll")),
+ MetadataReference.CreateFromFile(Path.Combine(assemblyPath, "net.dll")),
MetadataReference.CreateFromFile(Path.Combine(assemblyPath, "mscorlib.dll")),
MetadataReference.CreateFromFile(Path.Combine(assemblyPath, "System.dll")),
MetadataReference.CreateFromFile(Path.Combine(assemblyPath, "System.Core.dll")),
diff --git a/test/Directory.Build.targets b/test/Directory.Build.targets
index 3b3e8d7801a..edf51248c95 100644
--- a/test/Directory.Build.targets
+++ b/test/Directory.Build.targets
@@ -10,8 +10,8 @@
Orleans.CodeGenerator.MSBuild.Bootstrap
- $(MSBuildThisFileDirectory)../src/BootstrapBuild/$(Asm)/bin/$(Configuration)/publish/netcoreapp2.0/$(Asm).dll
- $(MSBuildThisFileDirectory)../src/BootstrapBuild/$(Asm)/bin/$(Configuration)/publish/netcoreapp2.0/Orleans.CodeGenerator.MSBuild.Tasks.dll
+ $(MSBuildThisFileDirectory)../src/BootstrapBuild/$(Asm)/bin/$(Configuration)/publish/net462/$(Asm).exe
+ $(MSBuildThisFileDirectory)../src/BootstrapBuild/$(Asm)/bin/$(Configuration)/publish/net462/Orleans.CodeGenerator.MSBuild.Tasks.dll
$(MSBuildThisFileDirectory)../src/BootstrapBuild/Orleans.CodeGenerator.MSBuild.Bootstrap/Orleans.CodeGenerator.MSBuild.Bootstrap.csproj
diff --git a/test/Grains/BenchmarkGrainInterfaces/BenchmarkGrainInterfaces.csproj b/test/Grains/BenchmarkGrainInterfaces/BenchmarkGrainInterfaces.csproj
index 8c3087da7af..6a8b81aa263 100644
--- a/test/Grains/BenchmarkGrainInterfaces/BenchmarkGrainInterfaces.csproj
+++ b/test/Grains/BenchmarkGrainInterfaces/BenchmarkGrainInterfaces.csproj
@@ -3,7 +3,7 @@
BenchmarkGrainInterfaces
BenchmarkGrainInterfaces
true
- netstandard2.0
+ net462
\ No newline at end of file
diff --git a/test/Grains/BenchmarkGrains/BenchmarkGrains.csproj b/test/Grains/BenchmarkGrains/BenchmarkGrains.csproj
index 2b3d549d816..09809b1381e 100644
--- a/test/Grains/BenchmarkGrains/BenchmarkGrains.csproj
+++ b/test/Grains/BenchmarkGrains/BenchmarkGrains.csproj
@@ -3,7 +3,7 @@
BenchmarkGrains
BenchmarkGrains
true
- netstandard2.0
+ net462
diff --git a/test/Grains/TestFSharp/TestFSharp.fsproj b/test/Grains/TestFSharp/TestFSharp.fsproj
index ff36ab7d150..775d1da4ec9 100644
--- a/test/Grains/TestFSharp/TestFSharp.fsproj
+++ b/test/Grains/TestFSharp/TestFSharp.fsproj
@@ -2,7 +2,7 @@
TestFSharp
TestFSharp
- netstandard2.0
+ net462
diff --git a/test/Grains/TestGrainInterfaces/ISampleStreamingGrain.cs b/test/Grains/TestGrainInterfaces/ISampleStreamingGrain.cs
index 1159aaab2fa..b3885a67553 100644
--- a/test/Grains/TestGrainInterfaces/ISampleStreamingGrain.cs
+++ b/test/Grains/TestGrainInterfaces/ISampleStreamingGrain.cs
@@ -30,9 +30,4 @@ public interface ISampleStreaming_ConsumerGrain : IGrainWithGuidKey
public interface ISampleStreaming_InlineConsumerGrain : ISampleStreaming_ConsumerGrain
{
}
-
- public interface IGrainWithGenericMethodsValue : IGrainWithGuidKey
- {
- ValueTask ValueTaskMethod(bool useCache);
- }
}
diff --git a/test/Grains/TestGrainInterfaces/TestGrainInterfaces.csproj b/test/Grains/TestGrainInterfaces/TestGrainInterfaces.csproj
index 8f65e0590b4..0e78f6048c0 100644
--- a/test/Grains/TestGrainInterfaces/TestGrainInterfaces.csproj
+++ b/test/Grains/TestGrainInterfaces/TestGrainInterfaces.csproj
@@ -2,17 +2,15 @@
UnitTests.GrainInterfaces
TestGrainInterfaces
- netstandard2.0
+ net462
true
-
-
diff --git a/test/Grains/TestGrains/TestGrains.csproj b/test/Grains/TestGrains/TestGrains.csproj
index 0cccc5dbbb3..b9cca7711a0 100644
--- a/test/Grains/TestGrains/TestGrains.csproj
+++ b/test/Grains/TestGrains/TestGrains.csproj
@@ -2,7 +2,7 @@
UnitTests.Grains
TestGrains
- netstandard2.0
+ net462
true
$(NoWarn);1591;1591;618
@@ -10,6 +10,5 @@
-
diff --git a/test/Grains/TestInternalGrainInterfaces/TestInternalGrainInterfaces.csproj b/test/Grains/TestInternalGrainInterfaces/TestInternalGrainInterfaces.csproj
index 8050ab379b1..721dd4ac8bc 100644
--- a/test/Grains/TestInternalGrainInterfaces/TestInternalGrainInterfaces.csproj
+++ b/test/Grains/TestInternalGrainInterfaces/TestInternalGrainInterfaces.csproj
@@ -3,7 +3,7 @@
UnitTests.GrainInterfaces
TestInternalGrainInterfaces
true
- netstandard2.0
+ net462
diff --git a/test/Grains/TestInternalGrains/TestInternalGrains.csproj b/test/Grains/TestInternalGrains/TestInternalGrains.csproj
index 46563dfbf7f..1a0521a53ca 100644
--- a/test/Grains/TestInternalGrains/TestInternalGrains.csproj
+++ b/test/Grains/TestInternalGrains/TestInternalGrains.csproj
@@ -2,7 +2,7 @@
UnitTests.Grains
TestInternalGrains
- netstandard2.0
+ net462
true
$(NoWarn);1591;1591;618
diff --git a/test/Misc/TestFSharpInterfaces/IFSharpBaseInterface.fs b/test/Misc/TestFSharpInterfaces/IFSharpBaseInterface.fs
deleted file mode 100644
index 14b412ae3f3..00000000000
--- a/test/Misc/TestFSharpInterfaces/IFSharpBaseInterface.fs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace UnitTests.FSharpInterfaces
-
-open System.Threading.Tasks
-
-type public IFSharpBaseInterface =
- abstract Echo: int -> Task
-
-
diff --git a/test/Misc/TestFSharpInterfaces/IFSharpParameters.fs b/test/Misc/TestFSharpInterfaces/IFSharpParameters.fs
deleted file mode 100644
index 0d7cd85da41..00000000000
--- a/test/Misc/TestFSharpInterfaces/IFSharpParameters.fs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace UnitTests.FSharpInterfaces
-
-open System.Threading.Tasks
-
-type public DiscriminatedUnion<'T> =
- | Nothing
- | Something of 'T
-
-type public IFSharpParameters<'T> =
- abstract OptionRoundtrip: 'T option -> Task<'T option>
-
diff --git a/test/Misc/TestFSharpInterfaces/TestFSharpInterfaces.fsproj b/test/Misc/TestFSharpInterfaces/TestFSharpInterfaces.fsproj
deleted file mode 100644
index c75148fe6a8..00000000000
--- a/test/Misc/TestFSharpInterfaces/TestFSharpInterfaces.fsproj
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- TestFSharpInterfaces
- TestFSharpInterfaces
- netstandard2.0
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/test/Misc/TestInterfaces/TestInterfaces.csproj b/test/Misc/TestInterfaces/TestInterfaces.csproj
index 3886b6f1fbf..2f2183f164a 100644
--- a/test/Misc/TestInterfaces/TestInterfaces.csproj
+++ b/test/Misc/TestInterfaces/TestInterfaces.csproj
@@ -2,7 +2,7 @@
UnitTests.Interfaces
TestInterfaces
- netstandard2.0
+ net462
diff --git a/test/Misc/TestInternalDtosRefOrleans/TestInternalDtosRefOrleans.csproj b/test/Misc/TestInternalDtosRefOrleans/TestInternalDtosRefOrleans.csproj
index 05642dfa522..3e7d69ada2e 100644
--- a/test/Misc/TestInternalDtosRefOrleans/TestInternalDtosRefOrleans.csproj
+++ b/test/Misc/TestInternalDtosRefOrleans/TestInternalDtosRefOrleans.csproj
@@ -2,7 +2,7 @@
TestInternalDtosRefOrleans
TestInternalDtosRefOrleans
- netstandard2.0
+ net462
true
diff --git a/test/NetCore.Tests/Directory.Build.props b/test/NetCore.Tests/Directory.Build.props
deleted file mode 100644
index c7014c8bdac..00000000000
--- a/test/NetCore.Tests/Directory.Build.props
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
- <_ParentDirectoryBuildPropsPath Condition="'$(_DirectoryBuildPropsFile)' != ''">$([System.IO.Path]::Combine('..', '$(_DirectoryBuildPropsFile)'))
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/test/NetCore.Tests/ExceptionTests.cs b/test/NetCore.Tests/ExceptionTests.cs
deleted file mode 100644
index f232bdd4c76..00000000000
--- a/test/NetCore.Tests/ExceptionTests.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-using Orleans;
-using Orleans.Hosting;
-using Orleans.Runtime.Configuration;
-using UnitTests.GrainInterfaces;
-using UnitTests.Grains;
-using Xunit;
-
-namespace NetCore.Tests
-{
- [Trait("Category", "BVT")]
- public class ExceptionTests : IDisposable
- {
- private readonly ISiloHost silo;
- private readonly IClusterClient client;
-
- public ExceptionTests()
- {
- this.silo = new SiloHostBuilder()
- .ConfigureApplicationParts(
- parts =>
- parts.AddApplicationPart(typeof(ExceptionGrain).Assembly).WithReferences())
- .UseLocalhostClustering()
- .Build();
- this.silo.StartAsync().GetAwaiter().GetResult();
-
- this.client = new ClientBuilder()
- .ConfigureApplicationParts(parts =>
- parts.AddApplicationPart(typeof(IExceptionGrain).Assembly).WithReferences())
- .UseLocalhostClustering()
- .Build();
- this.client.Connect().GetAwaiter().GetResult();
- }
-
- [Fact]
- public async Task ExceptionsPropagatedFromGrainToClient()
- {
- var grain = this.client.GetGrain(0);
-
- var invalidOperationException = await Assert.ThrowsAsync(() => grain.ThrowsInvalidOperationException());
- Assert.Equal("Test exception", invalidOperationException.Message);
-
- var nullReferenceException = await Assert.ThrowsAsync(() => grain.ThrowsNullReferenceException());
- Assert.Equal("null null null", nullReferenceException.Message);
- }
-
- public void Dispose()
- {
- var cancel = new CancellationTokenSource();
- cancel.Cancel();
- this.silo?.StopAsync(cancel.Token).GetAwaiter().GetResult();
- this.silo?.Dispose();
-
- this.client?.Abort();
- this.client?.Dispose();
- }
- }
-}
diff --git a/test/NetCore.Tests/NetCore.Tests.csproj b/test/NetCore.Tests/NetCore.Tests.csproj
deleted file mode 100644
index d2ea93938cf..00000000000
--- a/test/NetCore.Tests/NetCore.Tests.csproj
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
- netcoreapp2.0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/test/NonSilo.Tests/Serialization/SerializerGenerationTests.cs b/test/NonSilo.Tests/Serialization/SerializerGenerationTests.cs
index dbbf3288718..87005b9e082 100644
--- a/test/NonSilo.Tests/Serialization/SerializerGenerationTests.cs
+++ b/test/NonSilo.Tests/Serialization/SerializerGenerationTests.cs
@@ -30,7 +30,7 @@ public void SerializationTests_TypeWithInternalNestedClass()
{
var v = new MyTypeWithAnInternalTypeField();
- Assert.NotNull(this.fixture.SerializationManager.GetSerializer(typeof(MyTypeWithAnInternalTypeField)));
+ Assert.NotNull(this.fixture.SerializationManager.GetSerializer(typeof (MyTypeWithAnInternalTypeField)));
Assert.NotNull(this.fixture.SerializationManager.GetSerializer(typeof(MyTypeWithAnInternalTypeField.MyInternalDependency)));
}
@@ -42,12 +42,14 @@ public void SerializationTests_TypeWithWellKnownBaseClass()
{
Assert.NotNull(this.fixture.SerializationManager.GetSerializer(typeof(DescendantOfWellKnownBaseClass)));
Assert.NotNull(this.fixture.SerializationManager.GetSerializer(typeof(ImplementsWellKnownInterface)));
-
+ Assert.Null(this.fixture.SerializationManager.GetSerializer(typeof(NotDescendantOfWellKnownBaseType)));
+
var partManager = this.fixture.Services.GetRequiredService();
var serializerFeature = new SerializerFeature();
partManager.PopulateFeature(serializerFeature);
Assert.Contains(serializerFeature.SerializerTypes, s => s.Target == typeof(DescendantOfWellKnownBaseClass));
Assert.Contains(serializerFeature.SerializerTypes, s => s.Target == typeof(ImplementsWellKnownInterface));
+ Assert.DoesNotContain(serializerFeature.SerializerTypes, s => s.Target == typeof(NotDescendantOfWellKnownBaseType));
}
}
}
diff --git a/test/TestInfrastructure/Orleans.TestingHost.AppDomain/Orleans.TestingHost.AppDomain.csproj b/test/TestInfrastructure/Orleans.TestingHost.AppDomain/Orleans.TestingHost.AppDomain.csproj
index d37e80c630e..bdbde83637d 100644
--- a/test/TestInfrastructure/Orleans.TestingHost.AppDomain/Orleans.TestingHost.AppDomain.csproj
+++ b/test/TestInfrastructure/Orleans.TestingHost.AppDomain/Orleans.TestingHost.AppDomain.csproj
@@ -6,7 +6,7 @@
- net461
+ net462
Orleans.TestingHost.AppDomain
Orleans.TestingHost.AppDomain
diff --git a/test/TestInfrastructure/Orleans.TestingHost.Legacy/Orleans.TestingHost.Legacy.csproj b/test/TestInfrastructure/Orleans.TestingHost.Legacy/Orleans.TestingHost.Legacy.csproj
index df476c8c4e8..b580e65d821 100644
--- a/test/TestInfrastructure/Orleans.TestingHost.Legacy/Orleans.TestingHost.Legacy.csproj
+++ b/test/TestInfrastructure/Orleans.TestingHost.Legacy/Orleans.TestingHost.Legacy.csproj
@@ -6,7 +6,7 @@
- netstandard2.0
+ net462
Orleans.TestingHost.Legacy
Orleans.TestingHost.Legacy
true
diff --git a/test/TestInfrastructure/TestExtensions/TestExtensions.csproj b/test/TestInfrastructure/TestExtensions/TestExtensions.csproj
index 1729179ce99..4a470f089aa 100644
--- a/test/TestInfrastructure/TestExtensions/TestExtensions.csproj
+++ b/test/TestInfrastructure/TestExtensions/TestExtensions.csproj
@@ -2,7 +2,7 @@
TestExtensions
TestExtensions
- netstandard2.0
+ net462