Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions snippets/csharp/new-in-6/Enrollment.cs

This file was deleted.

15 changes: 0 additions & 15 deletions snippets/csharp/new-in-6/ExceptionFilterHelpers.cs

This file was deleted.

18 changes: 0 additions & 18 deletions snippets/csharp/new-in-6/NetworkClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,6 @@ public static async Task<string> MakeRequest()
}
// </ExceptionFilter>

// <HandleNotChanged>
public static async Task<string> MakeRequestWithNotModifiedSupport()
{
var client = new System.Net.Http.HttpClient();
var streamTask = client.GetStringAsync("https://localHost:10000");
try {
var responseText = await streamTask;
return responseText;
} catch (System.Net.Http.HttpRequestException e) when (e.Message.Contains("301"))
{
return "Site Moved";
} catch (System.Net.Http.HttpRequestException e) when (e.Message.Contains("304"))
{
return "Use the Cache";
}
}
// </HandleNotChanged>

// <AwaitFinally>
public static async Task<string> MakeRequestAndLogFailures()
{
Expand Down
29 changes: 0 additions & 29 deletions snippets/csharp/new-in-6/Newcode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ public Student(string firstName, string lastName)
// <Initialization>
public ICollection<double> Grades { get; } = new List<double>();
// </Initialization>
// <ReadWriteInitialization>
public Standing YearInSchool { get; set; } = Standing.Freshman;
// </ReadWriteInitialization>

// <FullNameExpressionMember>
public string FullName => $"{FirstName} {LastName}";
Expand All @@ -46,35 +43,9 @@ public Student(string firstName, string lastName)
public override string ToString() => $"{LastName}, {FirstName}";
// </ToStringExpressionMember>

// <stringInterpolationExpression>
public string GetFormattedGradePoint() =>
$"Name: {LastName}, {FirstName}. G.P.A: {Grades.Average()}";
// </stringInterpolationExpression>

// <stringInterpolationFormat>
public string GetGradePointPercentage() =>
$"Name: {LastName}, {FirstName}. G.P.A: {Grades.Average():F2}";
// </stringInterpolationFormat>

// <stringInterpolationConditional>
public string GetGradePointPercentages() =>
$"Name: {LastName}, {FirstName}. G.P.A: {(Grades.Any() ? Grades.Average() : double.NaN):F2}";
// </stringInterpolationConditional>

// <UsingStaticLinkMethod>
public bool MakesDeansList()
{
return Grades.All(g => g > 3.5) && Grades.Any();
// Code below generates CS0103:
// The name 'All' does not exist in the current context.
//return All(Grades, g => g > 3.5) && Grades.Any();
}
// </UsingStaticLinkMethod>

// <stringInterpolationLinq>
public string GetAllGrades() =>
$@"All Grades: {Grades.OrderByDescending(g => g)
.Select(s => s.ToString("F2")).Aggregate((partial, element) => $"{partial}, {element}")}";
// </stringInterpolationLinq>
}
}
54 changes: 0 additions & 54 deletions snippets/csharp/new-in-6/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Runtime.CompilerServices;
using static NewStyle.ExceptionExtensions;

namespace NewInCSharp6
{
Expand Down Expand Up @@ -33,61 +32,8 @@ public static void Main(string[] args)
test.Grades.Add(3.5);
test.Grades.Add(1.0);
test.Grades.Add(1.0);

Console.WriteLine(test.GetAllGrades());
}

// <LogException>
public void MethodThatFailsSometimes()
{
try {
PerformFailingOperation();
} catch (Exception e) when (e.LogException())
{
// This is never reached!
}
}
// </LogException>

// <LogExceptionRecovery>
public void MethodThatFailsButHasRecoveryPath()
{
try {
PerformFailingOperation();
} catch (Exception e) when (e.LogException())
{
// This is never reached!
}
catch (RecoverableException ex)
{
Console.WriteLine(ex.ToString());
// This can still catch the more specific
// exception because the exception filter
// above always returns false.
// Perform recovery here
}
}
// </LogExceptionRecovery>

// <LogExceptionDebugger>
public void MethodThatFailsWhenDebuggerIsNotAttached()
{
try {
PerformFailingOperation();
} catch (Exception e) when (e.LogException())
{
// This is never reached!
}
catch (RecoverableException ex) when (!System.Diagnostics.Debugger.IsAttached)
{
Console.WriteLine(ex.ToString());
// Only catch exceptions when a debugger is not attached.
// Otherwise, this should stop in the debugger.
}
}
// </LogExceptionDebugger>


private void PerformFailingOperation() {}
}

Expand Down
54 changes: 0 additions & 54 deletions snippets/csharp/new-in-6/classList.cs

This file was deleted.

3 changes: 3 additions & 0 deletions wpf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ If you're new to .NET Core, here are a few resources to help you understand the
## Samples in this repo
Coming soon!

## Additional Samples
See [WPF Samples](https://www.github.com/Microsoft/wpf-samples) repo for additional WPF samples that have been updated to target .NET Core 3.0.

## Getting Started

### Prerequisites and getting the tools
Expand Down