chore: format corrections

This commit is contained in:
Oli Sturm
2023-10-20 10:10:20 +01:00
parent a2d1e4adc2
commit 0957d0c6ed
11 changed files with 110 additions and 31 deletions
+13
View File
@@ -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
View File
@@ -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>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>
+6
View File
@@ -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>
+4 -5
View File
@@ -1,4 +1,6 @@
namespace CS10 { // ReSharper disable All
namespace CS10 {
class Program { class Program {
// Nested types, just like the C# 8 sample: // Nested types, just like the C# 8 sample:
public class Address { public class Address {
@@ -13,10 +15,7 @@
static void Main(string[] args) { static void Main(string[] args) {
// Nested property patterns, now shorter: // Nested property patterns, now shorter:
var customer = new Customer var customer = new Customer { Address = new Address { City = "Castle Douglas", Country = "UK" } };
{
Address = new Address { City = "Castle Douglas", Country = "UK" }
};
if (customer is { Address.City: "Castle Douglas" }) { if (customer is { Address.City: "Castle Douglas" }) {
Console.WriteLine("This customer lives around the corner"); Console.WriteLine("This customer lives around the corner");
} }
+4 -3
View File
@@ -1,4 +1,6 @@
namespace CS11 { // ReSharper disable All
namespace CS11 {
class Program { class Program {
static void Main(string[] args) { static void Main(string[] args) {
int[] numbers = { 1, 3, 42 }; int[] numbers = { 1, 3, 42 };
@@ -40,8 +42,7 @@
} }
// Now we're talking // Now we're talking
static int Sum(int[] l) => l switch static int Sum(int[] l) => l switch {
{
[] => 0, [] => 0,
[var x, .. var xs] => x + Sum(xs) [var x, .. var xs] => x + Sum(xs)
}; };
+3 -2
View File
@@ -1,4 +1,6 @@
namespace CS7 { // ReSharper disable All
namespace CS7 {
public class DeadPerson { public class DeadPerson {
public string Name { get; init; } = ""; public string Name { get; init; } = "";
public virtual bool IsAlive => false; public virtual bool IsAlive => false;
@@ -34,6 +36,5 @@
Console.WriteLine("My heartfelt apologies in case anybody finds my zombie sample offensive."); Console.WriteLine("My heartfelt apologies in case anybody finds my zombie sample offensive.");
} }
} }
} }
+5 -7
View File
@@ -1,8 +1,9 @@
namespace CS8 { // ReSharper disable All
namespace CS8 {
class Program { class Program {
// This is a "switch expression" // This is a "switch expression"
static int CalcResult(int input) => input switch static int CalcResult(int input) => input switch {
{
1 => 2, 1 => 2,
2 => 3, 2 => 3,
_ => throw new ArgumentException("Rien ne va plus") _ => throw new ArgumentException("Rien ne va plus")
@@ -33,10 +34,7 @@
Console.WriteLine($"Found Oli, his last name is {olisLastName}."); Console.WriteLine($"Found Oli, his last name is {olisLastName}.");
// Nested property patterns: // Nested property patterns:
var customer = new Customer var customer = new Customer { Address = new Address { City = "Castle Douglas", Country = "UK" } };
{
Address = new Address { City = "Castle Douglas", Country = "UK" }
};
if (customer is { Address: { City: "Castle Douglas" } }) { if (customer is { Address: { City: "Castle Douglas" } }) {
Console.WriteLine("This customer lives around the corner"); Console.WriteLine("This customer lives around the corner");
} }
+9 -6
View File
@@ -1,10 +1,13 @@
namespace CS9 { // ReSharper disable All
namespace CS9 {
class Program { class Program {
// Relational patterns (>= operator et al.) // Relational patterns (>= operator et al.)
// Logical patterns ("or", also "and" and "not") // Logical patterns ("or", also "and" and "not")
// Note: parens ( and ) can be used to determine precedence // Note: parens ( and ) can be used to determine precedence
bool IsPastMidYear(DateTime dt) => dt is { Month: >= 7 }; bool IsPastMidYear(DateTime dt) => dt is { Month: >= 7 };
bool IsThisYearOrLast(DateTime dt) => dt is { Year: 2022 or 2021 }; bool IsThisYearOrLast(DateTime dt) => dt is { Year: 2022 or 2021 };
bool IsSummer(DateTime dt) => dt is bool IsSummer(DateTime dt) => dt is
{ Month: 7 or 8 } or { Month: 7 or 8 } or
{ Month: 6, Day: >= 21 } or { Month: 6, Day: >= 21 } or
@@ -14,6 +17,7 @@
class Order { class Order {
public int ItemCount { get; set; } public int ItemCount { get; set; }
public double ItemPrice { get; set; } public double ItemPrice { get; set; }
public void Deconstruct(out int itemCount, out double itemPrice) { public void Deconstruct(out int itemCount, out double itemPrice) {
itemCount = ItemCount; itemCount = ItemCount;
itemPrice = ItemPrice; itemPrice = ItemPrice;
@@ -24,17 +28,16 @@
ValuableDueToHighCount, ValuableDueToHighCount,
ValuableDueToHighItemPrice, ValuableDueToHighItemPrice,
ValuableDueToHighTotal, ValuableDueToHighTotal,
NotValuable, NotValuable
} }
// Positional patterns with placeholders - note that // Positional patterns with placeholders - note that
// the element lists must be "complete"! // the element lists must be "complete"!
static OrderValue OrderValueCategory(Order o) => static OrderValue OrderValueCategory(Order o) =>
o switch o switch {
{ (< 0, _) => throw new ArgumentException("Positive itemCounts please!"),
( < 0, _) => throw new ArgumentException("Positive itemCounts please!"),
(_, < 0) => throw new ArgumentException("Positive itemPrices please!"), (_, < 0) => throw new ArgumentException("Positive itemPrices please!"),
( >= 100, _) => OrderValue.ValuableDueToHighCount, (>= 100, _) => OrderValue.ValuableDueToHighCount,
(_, >= 1000) => OrderValue.ValuableDueToHighItemPrice, (_, >= 1000) => OrderValue.ValuableDueToHighItemPrice,
// Assign variable names for further processing // Assign variable names for further processing
+1 -1
View File
@@ -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. // explicit pattern match.
let rec listLength l = let rec listLength l =
+46
View File
@@ -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