chore: format corrections
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider ignored files
|
||||
/contentModel.xml
|
||||
/modules.xml
|
||||
/projectSettingsUpdater.xml
|
||||
/.idea.samples.iml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace CS10 {
|
||||
// ReSharper disable All
|
||||
|
||||
namespace CS10 {
|
||||
class Program {
|
||||
// Nested types, just like the C# 8 sample:
|
||||
public class Address {
|
||||
@@ -13,10 +15,7 @@
|
||||
|
||||
static void Main(string[] args) {
|
||||
// Nested property patterns, now shorter:
|
||||
var customer = new Customer
|
||||
{
|
||||
Address = new Address { City = "Castle Douglas", Country = "UK" }
|
||||
};
|
||||
var customer = new Customer { Address = new Address { City = "Castle Douglas", Country = "UK" } };
|
||||
if (customer is { Address.City: "Castle Douglas" }) {
|
||||
Console.WriteLine("This customer lives around the corner");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace CS11 {
|
||||
// ReSharper disable All
|
||||
|
||||
namespace CS11 {
|
||||
class Program {
|
||||
static void Main(string[] args) {
|
||||
int[] numbers = { 1, 3, 42 };
|
||||
@@ -40,8 +42,7 @@
|
||||
}
|
||||
|
||||
// Now we're talking
|
||||
static int Sum(int[] l) => l switch
|
||||
{
|
||||
static int Sum(int[] l) => l switch {
|
||||
[] => 0,
|
||||
[var x, .. var xs] => x + Sum(xs)
|
||||
};
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace CS7 {
|
||||
// ReSharper disable All
|
||||
|
||||
namespace CS7 {
|
||||
public class DeadPerson {
|
||||
public string Name { get; init; } = "";
|
||||
public virtual bool IsAlive => false;
|
||||
@@ -34,6 +36,5 @@
|
||||
|
||||
Console.WriteLine("My heartfelt apologies in case anybody finds my zombie sample offensive.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
namespace CS8 {
|
||||
// ReSharper disable All
|
||||
|
||||
namespace CS8 {
|
||||
class Program {
|
||||
// This is a "switch expression"
|
||||
static int CalcResult(int input) => input switch
|
||||
{
|
||||
static int CalcResult(int input) => input switch {
|
||||
1 => 2,
|
||||
2 => 3,
|
||||
_ => throw new ArgumentException("Rien ne va plus")
|
||||
@@ -33,10 +34,7 @@
|
||||
Console.WriteLine($"Found Oli, his last name is {olisLastName}.");
|
||||
|
||||
// Nested property patterns:
|
||||
var customer = new Customer
|
||||
{
|
||||
Address = new Address { City = "Castle Douglas", Country = "UK" }
|
||||
};
|
||||
var customer = new Customer { Address = new Address { City = "Castle Douglas", Country = "UK" } };
|
||||
if (customer is { Address: { City: "Castle Douglas" } }) {
|
||||
Console.WriteLine("This customer lives around the corner");
|
||||
}
|
||||
|
||||
+12
-9
@@ -1,19 +1,23 @@
|
||||
namespace CS9 {
|
||||
// ReSharper disable All
|
||||
|
||||
namespace CS9 {
|
||||
class Program {
|
||||
// Relational patterns (>= operator et al.)
|
||||
// Logical patterns ("or", also "and" and "not")
|
||||
// Note: parens ( and ) can be used to determine precedence
|
||||
bool IsPastMidYear(DateTime dt) => dt is { Month: >= 7 };
|
||||
bool IsThisYearOrLast(DateTime dt) => dt is { Year: 2022 or 2021 };
|
||||
|
||||
bool IsSummer(DateTime dt) => dt is
|
||||
{ Month: 7 or 8 } or
|
||||
{ Month: 6, Day: >= 21 } or
|
||||
{ Month: 9, Day: < 21 };
|
||||
{ Month: 7 or 8 } or
|
||||
{ Month: 6, Day: >= 21 } or
|
||||
{ Month: 9, Day: < 21 };
|
||||
|
||||
// Class with "Deconstruct" implementation
|
||||
class Order {
|
||||
public int ItemCount { get; set; }
|
||||
public double ItemPrice { get; set; }
|
||||
|
||||
public void Deconstruct(out int itemCount, out double itemPrice) {
|
||||
itemCount = ItemCount;
|
||||
itemPrice = ItemPrice;
|
||||
@@ -24,17 +28,16 @@
|
||||
ValuableDueToHighCount,
|
||||
ValuableDueToHighItemPrice,
|
||||
ValuableDueToHighTotal,
|
||||
NotValuable,
|
||||
NotValuable
|
||||
}
|
||||
|
||||
// Positional patterns with placeholders - note that
|
||||
// the element lists must be "complete"!
|
||||
static OrderValue OrderValueCategory(Order o) =>
|
||||
o switch
|
||||
{
|
||||
( < 0, _) => throw new ArgumentException("Positive itemCounts please!"),
|
||||
o switch {
|
||||
(< 0, _) => throw new ArgumentException("Positive itemCounts please!"),
|
||||
(_, < 0) => throw new ArgumentException("Positive itemPrices please!"),
|
||||
( >= 100, _) => OrderValue.ValuableDueToHighCount,
|
||||
(>= 100, _) => OrderValue.ValuableDueToHighCount,
|
||||
(_, >= 1000) => OrderValue.ValuableDueToHighItemPrice,
|
||||
|
||||
// Assign variable names for further processing
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// In F# the keywoard `match` can be used to run an
|
||||
// In F# the keyword `match` can be used to run an
|
||||
// explicit pattern match.
|
||||
|
||||
let rec listLength l =
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.31903.59
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CS7", "CS7\CS7.csproj", "{90F0E6BB-4562-4F69-8DBA-95C1D01B5F7D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CS8", "CS8\CS8.csproj", "{D70FEF23-B303-431F-9A14-0F4478DFDAE7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CS9", "CS9\CS9.csproj", "{72390EA1-3D7A-4014-9AAC-2A4EED652350}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CS10", "CS10\CS10.csproj", "{ACDEF545-04C1-4F2D-96E3-041B3A2151B3}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CS11", "CS11\CS11.csproj", "{D1B3E6C4-303A-4A76-B555-4D78E50F8957}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{90F0E6BB-4562-4F69-8DBA-95C1D01B5F7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{90F0E6BB-4562-4F69-8DBA-95C1D01B5F7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{90F0E6BB-4562-4F69-8DBA-95C1D01B5F7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{90F0E6BB-4562-4F69-8DBA-95C1D01B5F7D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D70FEF23-B303-431F-9A14-0F4478DFDAE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D70FEF23-B303-431F-9A14-0F4478DFDAE7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D70FEF23-B303-431F-9A14-0F4478DFDAE7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D70FEF23-B303-431F-9A14-0F4478DFDAE7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{72390EA1-3D7A-4014-9AAC-2A4EED652350}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{72390EA1-3D7A-4014-9AAC-2A4EED652350}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{72390EA1-3D7A-4014-9AAC-2A4EED652350}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{72390EA1-3D7A-4014-9AAC-2A4EED652350}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{ACDEF545-04C1-4F2D-96E3-041B3A2151B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ACDEF545-04C1-4F2D-96E3-041B3A2151B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ACDEF545-04C1-4F2D-96E3-041B3A2151B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ACDEF545-04C1-4F2D-96E3-041B3A2151B3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D1B3E6C4-303A-4A76-B555-4D78E50F8957}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D1B3E6C4-303A-4A76-B555-4D78E50F8957}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D1B3E6C4-303A-4A76-B555-4D78E50F8957}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D1B3E6C4-303A-4A76-B555-4D78E50F8957}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Reference in New Issue
Block a user