diff --git a/.gitignore b/.gitignore
index e3636e1d..aa2790fb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,8 +41,6 @@ local.properties
*.user
*.sln.docstates
-launchSettings.json
-
# Roslyn (?) files
*.sln.ide
diff --git a/Abusing CSharp/Code/AbusingCSharp.sln b/Abusing CSharp/Code/AbusingCSharp.sln
deleted file mode 100644
index 5604120b..00000000
--- a/Abusing CSharp/Code/AbusingCSharp.sln
+++ /dev/null
@@ -1,100 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26020.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FunWithAwaiters", "FunWithAwaiters\FunWithAwaiters.csproj", "{3C95E21E-8080-4007-BD07-62ACDB4F02FE}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LinqToOperators", "LinqToOperators\LinqToOperators.csproj", "{3B6E7F7F-852F-4686-AFCC-1801E1AA614B}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WrappingAsync", "WrappingAsync\WrappingAsync.csproj", "{1C5FC668-B8AC-4B87-B053-BACAAD003DBF}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WhatTheHeck", "WhatTheHeck\WhatTheHeck.csproj", "{E3321E4F-EA4D-474C-ADBB-B2FA45BF1F51}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VersionDetection", "VersionDetection\VersionDetection.csproj", "{C69B3861-8D0D-4582-9E53-B03711ADF9A3}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VersionHelper", "VersionHelper\VersionHelper.csproj", "{DF7FC088-6A47-4C32-9D86-BAF31D8EECF4}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WhatTheHeck2", "WhatTheHeck2\WhatTheHeck2.csproj", "{2CED56D7-028F-474C-ABC3-6F332A61D32A}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OperatorAbuse", "OperatorAbuse\OperatorAbuse.csproj", "{633A7C59-06B0-44B1-94F7-877EE5E7D3B1}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OddsAndEnds", "OddsAndEnds\OddsAndEnds.csproj", "{7585BEF9-0348-4CC3-AA9E-C77DF3C5DE11}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Performance", "Performance\Performance.csproj", "{7B6AECB5-CCD7-4F91-9D8A-5CAF92B9EDA6}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StringInterpolation", "StringInterpolation\StringInterpolation.csproj", "{F66F5289-FCDF-41E9-AA8A-7D44BA122E5A}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExceptionFilters", "ExceptionFilters\ExceptionFilters.csproj", "{52F1308B-8861-40F1-8FDD-2FCA4AD29E38}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NullConditional", "NullConditional\NullConditional.csproj", "{E510ED31-7960-424E-90DB-B0C9B0C9B497}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Text", "Text", "{55FA2DC3-0C28-4722-9CEE-F450B1E3B310}"
- ProjectSection(SolutionItems) = preProject
- ..\Text\agenda.txt = ..\Text\agenda.txt
- ..\Text\intro.txt = ..\Text\intro.txt
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {3C95E21E-8080-4007-BD07-62ACDB4F02FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {3C95E21E-8080-4007-BD07-62ACDB4F02FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {3C95E21E-8080-4007-BD07-62ACDB4F02FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {3C95E21E-8080-4007-BD07-62ACDB4F02FE}.Release|Any CPU.Build.0 = Release|Any CPU
- {3B6E7F7F-852F-4686-AFCC-1801E1AA614B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {3B6E7F7F-852F-4686-AFCC-1801E1AA614B}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {3B6E7F7F-852F-4686-AFCC-1801E1AA614B}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {3B6E7F7F-852F-4686-AFCC-1801E1AA614B}.Release|Any CPU.Build.0 = Release|Any CPU
- {1C5FC668-B8AC-4B87-B053-BACAAD003DBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {1C5FC668-B8AC-4B87-B053-BACAAD003DBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {1C5FC668-B8AC-4B87-B053-BACAAD003DBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {1C5FC668-B8AC-4B87-B053-BACAAD003DBF}.Release|Any CPU.Build.0 = Release|Any CPU
- {E3321E4F-EA4D-474C-ADBB-B2FA45BF1F51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E3321E4F-EA4D-474C-ADBB-B2FA45BF1F51}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E3321E4F-EA4D-474C-ADBB-B2FA45BF1F51}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E3321E4F-EA4D-474C-ADBB-B2FA45BF1F51}.Release|Any CPU.Build.0 = Release|Any CPU
- {C69B3861-8D0D-4582-9E53-B03711ADF9A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {C69B3861-8D0D-4582-9E53-B03711ADF9A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {C69B3861-8D0D-4582-9E53-B03711ADF9A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {C69B3861-8D0D-4582-9E53-B03711ADF9A3}.Release|Any CPU.Build.0 = Release|Any CPU
- {DF7FC088-6A47-4C32-9D86-BAF31D8EECF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {DF7FC088-6A47-4C32-9D86-BAF31D8EECF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {DF7FC088-6A47-4C32-9D86-BAF31D8EECF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {DF7FC088-6A47-4C32-9D86-BAF31D8EECF4}.Release|Any CPU.Build.0 = Release|Any CPU
- {2CED56D7-028F-474C-ABC3-6F332A61D32A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {2CED56D7-028F-474C-ABC3-6F332A61D32A}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {2CED56D7-028F-474C-ABC3-6F332A61D32A}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {2CED56D7-028F-474C-ABC3-6F332A61D32A}.Release|Any CPU.Build.0 = Release|Any CPU
- {633A7C59-06B0-44B1-94F7-877EE5E7D3B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {633A7C59-06B0-44B1-94F7-877EE5E7D3B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {633A7C59-06B0-44B1-94F7-877EE5E7D3B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {633A7C59-06B0-44B1-94F7-877EE5E7D3B1}.Release|Any CPU.Build.0 = Release|Any CPU
- {7585BEF9-0348-4CC3-AA9E-C77DF3C5DE11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7585BEF9-0348-4CC3-AA9E-C77DF3C5DE11}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7585BEF9-0348-4CC3-AA9E-C77DF3C5DE11}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7585BEF9-0348-4CC3-AA9E-C77DF3C5DE11}.Release|Any CPU.Build.0 = Release|Any CPU
- {7B6AECB5-CCD7-4F91-9D8A-5CAF92B9EDA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7B6AECB5-CCD7-4F91-9D8A-5CAF92B9EDA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7B6AECB5-CCD7-4F91-9D8A-5CAF92B9EDA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7B6AECB5-CCD7-4F91-9D8A-5CAF92B9EDA6}.Release|Any CPU.Build.0 = Release|Any CPU
- {F66F5289-FCDF-41E9-AA8A-7D44BA122E5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {F66F5289-FCDF-41E9-AA8A-7D44BA122E5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {F66F5289-FCDF-41E9-AA8A-7D44BA122E5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {F66F5289-FCDF-41E9-AA8A-7D44BA122E5A}.Release|Any CPU.Build.0 = Release|Any CPU
- {52F1308B-8861-40F1-8FDD-2FCA4AD29E38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {52F1308B-8861-40F1-8FDD-2FCA4AD29E38}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {52F1308B-8861-40F1-8FDD-2FCA4AD29E38}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {52F1308B-8861-40F1-8FDD-2FCA4AD29E38}.Release|Any CPU.Build.0 = Release|Any CPU
- {E510ED31-7960-424E-90DB-B0C9B0C9B497}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E510ED31-7960-424E-90DB-B0C9B0C9B497}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E510ED31-7960-424E-90DB-B0C9B0C9B497}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E510ED31-7960-424E-90DB-B0C9B0C9B497}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/Abusing CSharp/Code/ExceptionFilters/App.config b/Abusing CSharp/Code/ExceptionFilters/App.config
deleted file mode 100644
index 88fa4027..00000000
--- a/Abusing CSharp/Code/ExceptionFilters/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Abusing CSharp/Code/ExceptionFilters/DirectThrowingFilter.cs b/Abusing CSharp/Code/ExceptionFilters/DirectThrowingFilter.cs
deleted file mode 100644
index caec79a3..00000000
--- a/Abusing CSharp/Code/ExceptionFilters/DirectThrowingFilter.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2017 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-using System;
-
-namespace ExceptionFilters
-{
- class DirectThrowingFilter
- {
- static void Main()
- {
- try
- {
- Foo();
- }
- catch (Exception e)
- {
- Console.WriteLine($"Exception: {e}");
- }
- }
-
- static void Foo()
- {
- try
- {
- Bar();
- }
- catch (Exception e) when (e.Message[10] == '!')
- {
- }
- }
-
- static void Bar()
- {
- throw new Exception("Bang!");
- }
- }
-}
diff --git a/Abusing CSharp/Code/ExceptionFilters/ExceptionContext.cs b/Abusing CSharp/Code/ExceptionFilters/ExceptionContext.cs
deleted file mode 100644
index 5f4b4407..00000000
--- a/Abusing CSharp/Code/ExceptionFilters/ExceptionContext.cs
+++ /dev/null
@@ -1,148 +0,0 @@
-// Copyright 2014 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Runtime.CompilerServices;
-
-namespace ExceptionFilters
-{
- class ExceptionContext
- {
- static void Main()
- {
- try
- {
- OuterMethod(10);
- }
- catch (IOException e)
- {
- Console.WriteLine("Exception: {0}", e);
- Console.WriteLine();
- e.DumpContext();
- }
- }
-
- static void OuterMethod(int n)
- {
- for (int i = 0; i < n; i++)
- {
- try
- {
- InnerMethod(i);
- }
- catch (Exception e) when (new LogContextEntry {[nameof(n)] = n,[nameof(i)] = i }.AddTo(e))
- { /* Never get here... */ }
- }
- }
-
- static void InnerMethod(int x)
- {
- try
- {
- if (x == 7)
- {
- GoBang();
- }
- }
- catch (Exception e) when (new LogContextEntry {[nameof(x)] = x,["now"] = DateTime.Now }.AddTo(e))
- { /* Never get here... */ }
- }
-
- static void GoBang()
- {
- try
- {
- throw new IOException("This is the exception");
- }
- finally
- {
- Console.WriteLine("Finally block!");
- }
- }
- }
-
- static class ExceptionExtensions
- {
- internal static List GetContext(this Exception e)
- {
- return (List)e.Data["context"];
- }
-
- internal static void DumpContext(this Exception e)
- {
- var list = e.GetContext();
- if (list == null)
- {
- return;
- }
- Console.WriteLine("Context:");
- foreach (var entry in list)
- {
- Console.WriteLine(entry);
- }
- }
-
- internal static void AddContext(this Exception e, LogContextEntry entry)
- {
- var list = e.GetContext();
- if (list == null)
- {
- list = new List();
- e.Data["context"] = list;
- }
- list.Add(entry);
- }
- }
-
- sealed class LogContextEntry : IEnumerable
- {
- public string File { get; }
- public string Member { get; }
- public int Line { get; }
-
- private readonly List keyOrder = new List();
- private readonly Dictionary values = new Dictionary();
-
-
- internal LogContextEntry([CallerFilePath] string file = null,
- [CallerMemberName] string member = null,
- [CallerLineNumber] int line = 0)
- {
- File = Path.GetFileName(file);
- Member = member;
- Line = line;
- }
-
- public object this[string key]
- {
- get { return values[key]; }
- set
- {
- if (!values.ContainsKey(key))
- {
- keyOrder.Add(key);
- }
- values[key] = value;
- }
- }
-
- public bool AddTo(Exception e)
- {
- e.AddContext(this);
- return false;
- }
-
- public override string ToString()
- {
- string valueText = string.Join(", ", keyOrder.Select(key => string.Format("${0} = {1}", key, values[key])));
- return string.Format("{0}:{1} ({2}) - {3}", File, Line, Member, valueText);
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- throw new NotImplementedException("Only implementing IEnumerable for collection initializers...");
- }
- }
-}
diff --git a/Abusing CSharp/Code/ExceptionFilters/ExceptionFilters.csproj b/Abusing CSharp/Code/ExceptionFilters/ExceptionFilters.csproj
deleted file mode 100644
index 46f0489f..00000000
--- a/Abusing CSharp/Code/ExceptionFilters/ExceptionFilters.csproj
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {52F1308B-8861-40F1-8FDD-2FCA4AD29E38}
- Exe
- ExceptionFilters
- ExceptionFilters
- v4.5.2
- 512
- true
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
- ExceptionFilters.Program
-
-
-
- ..\packages\JonSkeet.MiscUtil.0.1\lib\net35-Client\MiscUtil.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Abusing CSharp/Code/ExceptionFilters/Program.cs b/Abusing CSharp/Code/ExceptionFilters/Program.cs
deleted file mode 100644
index 9c4c1987..00000000
--- a/Abusing CSharp/Code/ExceptionFilters/Program.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2017 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-
-using MiscUtil;
-
-namespace ExceptionFilters
-{
- class Program
- {
- static void Main(string[] args)
- {
- ApplicationChooser.Run(typeof(Program), args);
- }
- }
-}
diff --git a/Abusing CSharp/Code/ExceptionFilters/Properties/AssemblyInfo.cs b/Abusing CSharp/Code/ExceptionFilters/Properties/AssemblyInfo.cs
deleted file mode 100644
index 87a70d7a..00000000
--- a/Abusing CSharp/Code/ExceptionFilters/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("ExceptionFilters")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("ExceptionFilters")]
-[assembly: AssemblyCopyright("Copyright © 2017")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("52f1308b-8861-40f1-8fdd-2fca4ad29e38")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Abusing CSharp/Code/ExceptionFilters/ReflectionThrowingFilter.cs b/Abusing CSharp/Code/ExceptionFilters/ReflectionThrowingFilter.cs
deleted file mode 100644
index 49165219..00000000
--- a/Abusing CSharp/Code/ExceptionFilters/ReflectionThrowingFilter.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2017 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-using System;
-
-namespace ExceptionFilters
-{
- class ReflectionThrowingFilter
- {
- static void Main()
- {
- Foo();
- }
-
- static void Foo()
- {
- try
- {
- Bar();
- }
- catch (Exception e) when (e.Message[10] == '!')
- {
- }
- }
-
- static void Bar()
- {
- throw new Exception("Bang!");
- }
- }
-}
diff --git a/Abusing CSharp/Code/ExceptionFilters/packages.config b/Abusing CSharp/Code/ExceptionFilters/packages.config
deleted file mode 100644
index 2e6072f0..00000000
--- a/Abusing CSharp/Code/ExceptionFilters/packages.config
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/Abusing CSharp/Code/FunWithAwaiters/App.config b/Abusing CSharp/Code/FunWithAwaiters/App.config
deleted file mode 100644
index 8e156463..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Abusing CSharp/Code/FunWithAwaiters/AsyncStateMachineExtensions.cs b/Abusing CSharp/Code/FunWithAwaiters/AsyncStateMachineExtensions.cs
deleted file mode 100644
index bce834c2..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/AsyncStateMachineExtensions.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright 2013 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-using System;
-using System.IO;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-
-namespace FunWithAwaiters
-{
- public static class AsyncStateMachineExtensions
- {
- public static int GetState(this IAsyncStateMachine stateMachine)
- {
- return (int) stateMachine.GetStateField().GetValue(stateMachine);
- }
-
- public static void SetState(this IAsyncStateMachine stateMachine, int state)
- {
- stateMachine.GetStateField().SetValue(stateMachine, state);
- }
-
- public static Action GetActionForState(this IAsyncStateMachine stateMachine, int state)
- {
- return () =>
- {
- stateMachine.SetState(state);
- stateMachine.MoveNext();
- };
- }
-
- private static FieldInfo GetStateField(this IAsyncStateMachine stateMachine)
- {
- return stateMachine.GetType().GetField("<>1__state");
- }
-
- public static void SaveTo(this IAsyncStateMachine stateMachine, string file)
- {
- using (var stream = File.Create(file))
- {
- SerializationUtil.SerializeFields(stateMachine, stream, ShouldSerialize);
- }
- }
-
- public static void LoadFrom(this IAsyncStateMachine target, string file)
- {
- using (var stream = File.OpenRead(file))
- {
- SerializationUtil.DeserializeFields(target, stream);
- }
- }
-
- public static void SaveTo(this IAsyncStateMachine stateMachine, Stream stream)
- {
- SerializationUtil.SerializeFields(stateMachine, stream, ShouldSerialize);
- }
-
- public static void LoadFrom(this IAsyncStateMachine target, Stream stream)
- {
- SerializationUtil.DeserializeFields(target, stream);
- }
-
- // This is all down to experimentation...
- private static bool ShouldSerialize(FieldInfo field)
- {
- if (typeof(ITransient).IsAssignableFrom(field.FieldType))
- {
- return false;
- }
-
- string name = field.Name;
- // Parameters end up just with the same name as the original.
- // Local variables end up with the identifier in the angle brackets, e.g.
- if (!name.StartsWith("<>"))
- {
- return true;
- }
-
- // <>1__state will hold the state, which we do want to serialize.
- // <>7__wrap* holds things like extra variables for iterators and using statements.
- // <>t__builder holds the AsyncTaskMethodBuilder (or whatever) - we don't want that
- // <>u__%awaiter* holds awaiters
- // (More TBD?)
- return char.IsDigit(name[2]);
- }
- }
-}
diff --git a/Abusing CSharp/Code/FunWithAwaiters/AsyncUtil.cs b/Abusing CSharp/Code/FunWithAwaiters/AsyncUtil.cs
deleted file mode 100644
index 31e4fb5d..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/AsyncUtil.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2013 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-using System;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-
-namespace FunWithAwaiters
-{
- public static class AsyncUtil
- {
- public static IAsyncStateMachine GetStateMachine(Action continuation)
- {
- var target = continuation.Target;
- var field = target.GetType().GetField("m_stateMachine", BindingFlags.NonPublic | BindingFlags.Instance);
- return (IAsyncStateMachine) field.GetValue(target);
- }
- }
-}
diff --git a/Abusing CSharp/Code/FunWithAwaiters/AwaiterExtensions.cs b/Abusing CSharp/Code/FunWithAwaiters/AwaiterExtensions.cs
deleted file mode 100644
index 4a4d09a0..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/AwaiterExtensions.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2013 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-
-namespace FunWithAwaiters
-{
- public static class AwaiterExtensions
- {
- private class Awaitable : IAwaitable
- {
- private readonly IAwaiter awaiter;
-
- internal Awaitable(IAwaiter awaiter)
- {
- this.awaiter = awaiter;
- }
-
- public IAwaiter GetAwaiter()
- {
- return awaiter;
- }
- }
-
- public static IAwaitable NewAwaitable(this IAwaiter awaiter)
- {
- return new Awaitable(awaiter);
- }
-
- private class Awaitable : IAwaitable
- {
- private readonly IAwaiter awaiter;
-
- internal Awaitable(IAwaiter awaiter)
- {
- this.awaiter = awaiter;
- }
-
- public IAwaiter GetAwaiter()
- {
- return awaiter;
- }
- }
-
- public static IAwaitable NewAwaitable(this IAwaiter awaiter)
- {
- return new Awaitable(awaiter);
- }
- }
-}
diff --git a/Abusing CSharp/Code/FunWithAwaiters/Executioner.cs b/Abusing CSharp/Code/FunWithAwaiters/Executioner.cs
deleted file mode 100644
index 096c1104..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/Executioner.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright 2013 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-
-using System;
-using System.Runtime.CompilerServices;
-
-namespace FunWithAwaiters
-{
- ///
- /// Simple class to control execution: it just keeps executing actions until it's completed.
- /// Awaitables can be created which will always make the generated code yield and pass the state
- /// machine to a handler.
- ///
- public class Executioner : ITransient
- {
- private readonly Action entryPoint;
- private Action nextAction;
-
- public Executioner(Action entryPoint)
- {
- this.entryPoint = entryPoint;
- }
-
- public void Start()
- {
- Execute(entryPoint);
- }
-
- protected void Execute(Action action)
- {
- nextAction = () => action(this);
- while (nextAction != null)
- {
- Action next = nextAction;
- nextAction = null;
- next();
- }
- }
-
- public IAwaitable CreateAwaitable(Action stateMachineHandler)
- {
- var awaiter = new YieldingAwaiter(continuation =>
- {
- var machine = AsyncUtil.GetStateMachine(continuation);
- stateMachineHandler(machine);
- nextAction = continuation;
- });
- return awaiter.NewAwaitable();
- }
-
- public IAwaitable CreateAwaitable(Func stateMachineHandler)
- {
- var awaiter = new YieldingAwaiter(continuation =>
- {
- var machine = AsyncUtil.GetStateMachine(continuation);
- nextAction = stateMachineHandler(machine);
- });
- return awaiter.NewAwaitable();
- }
-
- public YieldingAwaitable CreateYieldingAwaitable(Action stateMachineHandler, T result)
- {
- var awaiter = new YieldingAwaiter(continuation =>
- {
- var machine = AsyncUtil.GetStateMachine(continuation);
- stateMachineHandler(machine);
- nextAction = continuation;
- }, result);
- return new YieldingAwaitable(awaiter);
- }
-
- public YieldingAwaitable CreateYieldingAwaitable(Func stateMachineHandler, T value)
- {
- var awaiter = new YieldingAwaiter(continuation =>
- {
- var machine = AsyncUtil.GetStateMachine(continuation);
- nextAction = stateMachineHandler(machine);
- }, value);
- return new YieldingAwaitable(awaiter);
- }
- }
-}
diff --git a/Abusing CSharp/Code/FunWithAwaiters/FunWithAwaiters.csproj b/Abusing CSharp/Code/FunWithAwaiters/FunWithAwaiters.csproj
deleted file mode 100644
index ab9f1deb..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/FunWithAwaiters.csproj
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {3C95E21E-8080-4007-BD07-62ACDB4F02FE}
- Exe
- Properties
- FunWithAwaiters
- FunWithAwaiters
- v4.5
- 512
- ..\
- true
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
- FunWithAwaiters.Program
-
-
-
- ..\packages\JonSkeet.MiscUtil.0.1\lib\net35-Client\MiscUtil.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Abusing CSharp/Code/FunWithAwaiters/GotoAsync.cs b/Abusing CSharp/Code/FunWithAwaiters/GotoAsync.cs
deleted file mode 100644
index 21050483..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/GotoAsync.cs
+++ /dev/null
@@ -1,27 +0,0 @@
- // Copyright 2013 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
- using System;
- using System.ComponentModel;
-
- namespace FunWithAwaiters
- {
- [Description("Goto (async style)")]
- class GotoAsync
- {
- private static void Main()
- {
- var executioner = new GotoExecutioner(Entry);
- executioner.Start();
- }
-
- private static async void Entry(LineAction _, GotoAction @goto)
- {
-await _(); Console.WriteLine("Hello");
-await _(); Console.Write("Keep going? ");
-await _(); string line = Console.ReadLine();
-await _(); if (line == "y") {
-await _(); await @goto(19);
-await _(); }
-await _(); Console.WriteLine("Finished!");
- }
- }
- }
diff --git a/Abusing CSharp/Code/FunWithAwaiters/GotoExecutioner.cs b/Abusing CSharp/Code/FunWithAwaiters/GotoExecutioner.cs
deleted file mode 100644
index 0bff3d5f..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/GotoExecutioner.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2013 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-using System;
-using System.Collections.Generic;
-using System.Runtime.CompilerServices;
-
-namespace FunWithAwaiters
-{
- public delegate IAwaitable LineAction([CallerLineNumber] int line = 0);
- public delegate IAwaitable GotoAction(int line);
-
- public class GotoExecutioner : Executioner
- {
- private readonly Dictionary lineToStateMap = new Dictionary();
-
- public GotoExecutioner(Action entryPoint) : base(exec => entryPoint(((GotoExecutioner)exec).Line, ((GotoExecutioner)exec).Goto))
- {
- }
-
- public IAwaitable Line([CallerLineNumber] int line = 0)
- {
- return CreateAwaitable(stateMachine => lineToStateMap[line] = stateMachine.GetState());
- }
-
- public IAwaitable Goto(int line)
- {
- return CreateAwaitable(stateMachine => stateMachine.GetActionForState(lineToStateMap[line]));
- }
- }
-}
diff --git a/Abusing CSharp/Code/FunWithAwaiters/GotoLabels.cs b/Abusing CSharp/Code/FunWithAwaiters/GotoLabels.cs
deleted file mode 100644
index d2ac1952..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/GotoLabels.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2013 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-using System;
-using System.ComponentModel;
-
-namespace FunWithAwaiters
-{
- [Description("Goto (with labels)")]
- class GotoLabels
- {
- static void Main()
- {
- Console.WriteLine("Hello");
- loop:
- Console.Write("Keep going? ");
- string line = Console.ReadLine();
- if (line == "y")
- {
- goto loop;
- }
- Console.WriteLine("Finished!");
- }
- }
-}
diff --git a/Abusing CSharp/Code/FunWithAwaiters/GotoMethodAsync.cs b/Abusing CSharp/Code/FunWithAwaiters/GotoMethodAsync.cs
deleted file mode 100644
index 93a0c8ef..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/GotoMethodAsync.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace FunWithAwaiters
-{
- class GotoMethodAsync
- {
- static void Main()
- {
- var executioner = new GotoMethodExecutioner(Entry, Entry, Foo, Bar);
- Console.WriteLine("Starting");
- executioner.Start();
- }
-
- static async void Entry(MethodLineAction _, MethodGotoAction @goto)
- {
-if (!await _()) await @goto("Foo:2");
- }
-
- static async void Foo(MethodLineAction _, MethodGotoAction @goto)
- {
-#line 1
-if (!await _()) Console.WriteLine("Foo1");
-if (!await _()) Console.WriteLine("Foo2");
-if (!await _()) await @goto("Bar:1");
-if (!await _()) Console.WriteLine("Foo4");
- }
-
- static async void Bar(MethodLineAction _, MethodGotoAction @goto)
- {
-#line 1
-if (!await _()) Console.WriteLine("Bar1");
-if (!await _()) Console.WriteLine("Bar2");
-if (!await _()) await @goto("Foo:4");
-if (!await _()) Console.WriteLine("Bar3");
- }
- }
-}
diff --git a/Abusing CSharp/Code/FunWithAwaiters/GotoMethodExecutioner.cs b/Abusing CSharp/Code/FunWithAwaiters/GotoMethodExecutioner.cs
deleted file mode 100644
index 1ee3bf99..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/GotoMethodExecutioner.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Runtime.CompilerServices;
-
-namespace FunWithAwaiters
-{
- public delegate YieldingAwaitable MethodLineAction([CallerMemberName] string method = null, [CallerLineNumber] int line = 0);
- public delegate YieldingAwaitable MethodGotoAction(string label);
-
- class GotoMethodExecutioner : Executioner
- {
- private readonly Dictionary labelToActionMap = new Dictionary();
-
- private readonly bool recording = true; // Urrrgh!
-
- public GotoMethodExecutioner(Action entryPoint,
- params Action[] actions)
- : base(exec => entryPoint(((GotoMethodExecutioner) exec).Line, ((GotoMethodExecutioner) exec).Goto))
- {
- foreach (var action in actions)
- {
- Execute(_ => action(Line, Goto));
- }
- recording = false;
- }
-
- public YieldingAwaitable Line([CallerMemberName] string method = null, [CallerLineNumber] int line = 0)
- {
- string label = method + ":" + line;
- return CreateYieldingAwaitable(stateMachine =>
- labelToActionMap[label] = stateMachine.GetActionForState(stateMachine.GetState()),
- recording);
- }
-
- public YieldingAwaitable Goto(string label)
- {
- return CreateYieldingAwaitable(stateMachine => labelToActionMap[label], false);
- }
- }
-}
diff --git a/Abusing CSharp/Code/FunWithAwaiters/IAwaitable.cs b/Abusing CSharp/Code/FunWithAwaiters/IAwaitable.cs
deleted file mode 100644
index cba5e8c3..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/IAwaitable.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2013 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-
-namespace FunWithAwaiters
-{
- public interface IAwaitable
- {
- IAwaiter GetAwaiter();
- }
-
- public interface IAwaitable
- {
- IAwaiter GetAwaiter();
- }
-}
diff --git a/Abusing CSharp/Code/FunWithAwaiters/IAwaiter.cs b/Abusing CSharp/Code/FunWithAwaiters/IAwaiter.cs
deleted file mode 100644
index 194809e4..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/IAwaiter.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2013 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-
-using System.Runtime.CompilerServices;
-
-namespace FunWithAwaiters
-{
- public interface IAwaiter : INotifyCompletion
- {
- bool IsCompleted { get; }
- void GetResult();
- }
-
- public interface IAwaiter : INotifyCompletion
- {
- bool IsCompleted { get; }
- T GetResult();
- }
-}
diff --git a/Abusing CSharp/Code/FunWithAwaiters/ITransient.cs b/Abusing CSharp/Code/FunWithAwaiters/ITransient.cs
deleted file mode 100644
index 4dce48fb..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/ITransient.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-// Copyright 2013 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-
-namespace FunWithAwaiters
-{
- interface ITransient
- {
- }
-}
diff --git a/Abusing CSharp/Code/FunWithAwaiters/Program.cs b/Abusing CSharp/Code/FunWithAwaiters/Program.cs
deleted file mode 100644
index d49649b3..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/Program.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2013 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-
-using MiscUtil;
-
-namespace FunWithAwaiters
-{
- class Program
- {
- static void Main(string[] args)
- {
- ApplicationChooser.Run(typeof(Program), args);
- }
- }
-}
diff --git a/Abusing CSharp/Code/FunWithAwaiters/Properties/AssemblyInfo.cs b/Abusing CSharp/Code/FunWithAwaiters/Properties/AssemblyInfo.cs
deleted file mode 100644
index b71638ad..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("CompilerAnguish")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("CompilerAnguish")]
-[assembly: AssemblyCopyright("Copyright © 2012")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("729e427f-fdbb-49ae-9beb-38a5e87942be")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Abusing CSharp/Code/FunWithAwaiters/Retry.cs b/Abusing CSharp/Code/FunWithAwaiters/Retry.cs
deleted file mode 100644
index 20c04d44..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/Retry.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2013 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-
-using System;
-using System.Threading.Tasks;
-
-namespace FunWithAwaiters
-{
- class Retry
- {
- static readonly Random rng = new Random();
-
- static void Main()
- {
- RetryingExecutioner executioner = new RetryingExecutioner(ShowRetries);
- executioner.Start();
- }
-
- static async Task ShowRetries(RetryingExecutioner executioner)
- {
- await executioner.Setup();
- for (int i = 0; i < 10; i++)
- {
- Console.WriteLine("Step {0}: trying to roll a 6...", i);
- await executioner.Retry(20);
- MustRoll6();
- }
- Console.WriteLine("Phew!");
- }
-
- static void MustRoll6()
- {
- int roll = rng.Next(1, 7);
- Console.WriteLine("Rolled {0}", roll);
- if (roll != 6)
- {
- throw new Exception("You didn't roll a 6!");
- }
- }
- }
-}
diff --git a/Abusing CSharp/Code/FunWithAwaiters/RetryingExecutioner.cs b/Abusing CSharp/Code/FunWithAwaiters/RetryingExecutioner.cs
deleted file mode 100644
index 3144b837..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/RetryingExecutioner.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright 2013 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-
-using System;
-using System.IO;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-
-namespace FunWithAwaiters
-{
- public class RetryingExecutioner : ITransient
- {
- private Action machineContinuation;
- private IAsyncStateMachine stateMachine;
-
- private byte[] savedState;
- private int retryCount;
- private int retryMax;
- private readonly Func entryPoint;
-
- public RetryingExecutioner(Func entryPoint)
- {
- this.entryPoint = entryPoint;
- }
-
- public void Start()
- {
- Task task = entryPoint(this);
- while (true)
- {
- if (task.Status == TaskStatus.RanToCompletion || task.IsCanceled)
- {
- return;
- }
- if (task.IsFaulted)
- {
- retryCount++;
- if (savedState == null || machineContinuation == null || stateMachine == null || retryCount == retryMax)
- {
- Console.WriteLine(" Retry limit exceeded. Rethrowing...");
- throw task.Exception.InnerExceptions[0];
- }
- //Console.WriteLine("Handled exception: {0}", task.Exception.InnerExceptions[0].Message);
- Console.WriteLine(" Retrying: {0} out of {1}", retryCount, retryMax);
- task = entryPoint(this);
- }
- else
- {
- machineContinuation();
- }
- }
- }
-
- public IAwaitable Setup()
- {
- var awaiter = new YieldingAwaiter(continuation =>
- {
- stateMachine = AsyncUtil.GetStateMachine(continuation);
- machineContinuation = continuation;
- if (savedState == null)
- {
- SaveState(stateMachine);
- }
- else
- {
- stateMachine.LoadFrom(new MemoryStream(savedState));
- }
- });
- return awaiter.NewAwaitable();
- }
-
- public IAwaitable Retry(int times)
- {
- var awaiter = new YieldingAwaiter(continuation =>
- {
- retryCount = 0;
- retryMax = times;
- SaveState(stateMachine);
- });
- return awaiter.NewAwaitable();
- }
-
- private void SaveState(IAsyncStateMachine stateMachine)
- {
- using (var stream = new MemoryStream())
- {
- stateMachine.SaveTo(stream);
- savedState = stream.ToArray();
- }
- }
- }
-}
diff --git a/Abusing CSharp/Code/FunWithAwaiters/SaveState.cs b/Abusing CSharp/Code/FunWithAwaiters/SaveState.cs
deleted file mode 100644
index c6ef24e3..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/SaveState.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2013 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-
-using System;
-using System.IO;
-using System.Runtime.CompilerServices;
-
-namespace FunWithAwaiters
-{
- class SaveState
- {
- static void Main(string[] args)
- {
- var executioner = new Executioner(SaveResumeDemo);
- executioner.Start();
- }
-
- static async void SaveResumeDemo(Executioner executioner)
- {
- if (File.Exists("state.dat"))
- {
- await executioner.CreateAwaitable(machine => machine.LoadFrom("state.dat"));
- Console.WriteLine("We'll never get here");
- }
- Console.WriteLine("Looks like this is the first time through");
- string startTime = DateTime.Now.ToString();
- for (int i = 0; i < 10; i++)
- {
- await executioner.CreateAwaitable(machine => machine.SaveTo("state.dat"));
- Console.WriteLine("Started at: {0}", startTime);
- Console.WriteLine("i = {0}. Continue? ", i);
- string text = Console.ReadLine();
- if (text == "n")
- {
- return;
- }
- }
- Console.WriteLine("Completed!");
- File.Delete("state.dat");
- }
- }
-
- internal class SimpleAwaiter : IAwaiter
- {
- private IAsyncStateMachine machine;
-
- public bool IsCompleted
- {
- get { return false; }
- }
-
- public IAsyncStateMachine GetResult()
- {
- return machine;
- }
-
- public void OnCompleted(Action continuation)
- {
- machine = AsyncUtil.GetStateMachine(continuation);
- continuation();
- }
- }
-}
diff --git a/Abusing CSharp/Code/FunWithAwaiters/SerializationUtil.cs b/Abusing CSharp/Code/FunWithAwaiters/SerializationUtil.cs
deleted file mode 100644
index 9ac4c443..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/SerializationUtil.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2013 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-
-using System;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-using System.Runtime.Serialization.Formatters.Binary;
-
-namespace FunWithAwaiters
-{
- public static class SerializationUtil
- {
- public static void SerializeFields(object source, Stream stream, Func predicate)
- {
- var formatter = new BinaryFormatter();
- foreach (var field in source.GetType()
- .GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
- .Where(predicate))
- {
- object value = field.GetValue(source) ?? NullToken.Instance;
- formatter.Serialize(stream, field.Name);
- formatter.Serialize(stream, value);
- }
- }
-
- public static void DeserializeFields(object target, Stream stream)
- {
- var formatter = new BinaryFormatter();
- long length = stream.Length;
- while (stream.Position != length)
- {
- string name = (string) formatter.Deserialize(stream);
- object value = formatter.Deserialize(stream);
- if (value is NullToken)
- {
- value = null;
- }
- target.GetType()
- .GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
- .SetValue(target, value);
- }
- }
-
- [Serializable]
- private class NullToken
- {
- public static readonly NullToken Instance = new NullToken();
-
- // No need to actually make this a singleton...
- }
- }
-}
diff --git a/Abusing CSharp/Code/FunWithAwaiters/YieldingAwaiter.cs b/Abusing CSharp/Code/FunWithAwaiters/YieldingAwaiter.cs
deleted file mode 100644
index a353d23a..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/YieldingAwaiter.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2013 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-
-using System;
-
-namespace FunWithAwaiters
-{
- public struct YieldingAwaiter : IAwaiter
- {
- private readonly Action onCompletedHandler;
-
- public YieldingAwaiter(Action onCompletedHandler)
- {
- this.onCompletedHandler = onCompletedHandler;
- }
-
- public bool IsCompleted { get { return false; } }
-
- public void GetResult()
- {
- }
-
- public void OnCompleted(Action continuation)
- {
- onCompletedHandler(continuation);
- }
- }
-
- public class YieldingAwaitable
- {
- private readonly YieldingAwaiter awaiter;
-
- internal YieldingAwaitable(YieldingAwaiter awaiter)
- {
- this.awaiter = awaiter;
- }
-
- public YieldingAwaiter GetAwaiter()
- {
- return awaiter;
- }
- }
-
- public struct YieldingAwaiter : IAwaiter
- {
- private readonly Action onCompletedHandler;
- private readonly T result;
-
- public YieldingAwaiter(Action onCompletedHandler, T result)
- {
- this.onCompletedHandler = onCompletedHandler;
- this.result = result;
- }
-
- public bool IsCompleted { get { return false; } }
-
- public T GetResult()
- {
- return result;
- }
-
- public void OnCompleted(Action continuation)
- {
- onCompletedHandler(continuation);
- }
- }
-}
diff --git a/Abusing CSharp/Code/FunWithAwaiters/goto.txt b/Abusing CSharp/Code/FunWithAwaiters/goto.txt
deleted file mode 100644
index bcbdb051..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/goto.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-10 PRINT "Hello"
-20 INPUT "Keep going"; LINE
-30 IF LINE = "y" THEN GOTO 20
-40 PRINT "Finished!"
diff --git a/Abusing CSharp/Code/FunWithAwaiters/packages.config b/Abusing CSharp/Code/FunWithAwaiters/packages.config
deleted file mode 100644
index b15b2ca1..00000000
--- a/Abusing CSharp/Code/FunWithAwaiters/packages.config
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/Abusing CSharp/Code/LinqToOperators/App.config b/Abusing CSharp/Code/LinqToOperators/App.config
deleted file mode 100644
index 8e156463..00000000
--- a/Abusing CSharp/Code/LinqToOperators/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Abusing CSharp/Code/LinqToOperators/BasicDemo.cs b/Abusing CSharp/Code/LinqToOperators/BasicDemo.cs
deleted file mode 100644
index c1d24cbc..00000000
--- a/Abusing CSharp/Code/LinqToOperators/BasicDemo.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2013 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-using System;
-
-namespace LinqToOperators
-{
- class BasicDemo
- {
- static void Main(string[] args)
- {
- var funky = new[] { "hello", "world", "how", "are", "you" };
- var query = funky.Evil() - "world" + "today"
- & (x => x.Length == 5)
- | (x => x.ToUpper());
-
- Console.WriteLine(query * 3);
-
- var xor1 = new[] { "foo", "bar", "baz" }.Evil();
- var xor2 = new[] { "qux", "bar" }.Evil();
- Console.WriteLine(xor1 ^ xor2);
- }
- }
-}
diff --git a/Abusing CSharp/Code/LinqToOperators/Comparisons.cs b/Abusing CSharp/Code/LinqToOperators/Comparisons.cs
deleted file mode 100644
index 69809441..00000000
--- a/Abusing CSharp/Code/LinqToOperators/Comparisons.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2013 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-using System;
-using System.Collections;
-
-namespace LinqToOperators
-{
- class Comparisons
- {
- static void Main()
- {
- Compare(new[] { 1, 4, 2, 6, 3 }, new[] { 1, 4, 5 });
- Compare(new[] { "hello", "there", "world" }, new[] { "hello", "there" });
- Compare(new[] { 6, 3, 4 }, new[] { 6, 3, 4 });
- }
-
- static void Compare(IEnumerable lhs, IEnumerable rhs)
- {
- var evilLeft = lhs.Evil();
- Console.WriteLine("Left: {0}", evilLeft);
- Console.WriteLine("Right: {0}", rhs.Evil());
- Console.WriteLine("== {0}", evilLeft == rhs);
- Console.WriteLine("!= {0}", evilLeft != rhs);
- Console.WriteLine("> {0}", evilLeft > rhs);
- Console.WriteLine(">= {0}", evilLeft >= rhs);
- Console.WriteLine("< {0}", evilLeft < rhs);
- Console.WriteLine("<= {0}", evilLeft <= rhs);
- Console.WriteLine();
- }
- }
-}
diff --git a/Abusing CSharp/Code/LinqToOperators/CrossMultiply.cs b/Abusing CSharp/Code/LinqToOperators/CrossMultiply.cs
deleted file mode 100644
index f3b9e5c3..00000000
--- a/Abusing CSharp/Code/LinqToOperators/CrossMultiply.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2013 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-using System;
-
-namespace LinqToOperators
-{
- class CrossMultiply
- {
- static void Main()
- {
- var input1 = new[] {"a", "b", "c"}.Evil();
- var input2 = new[] {1, 2, 3};
-
- Console.WriteLine(input1 * input2);
- }
- }
-}
diff --git a/Abusing CSharp/Code/LinqToOperators/DarkEnumerable.cs b/Abusing CSharp/Code/LinqToOperators/DarkEnumerable.cs
deleted file mode 100644
index 56c2697f..00000000
--- a/Abusing CSharp/Code/LinqToOperators/DarkEnumerable.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2013 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
-using System.Collections.Generic;
-
-namespace LinqToOperators
-{
- public sealed class DarkEnumerable
- {
- private readonly IEnumerable