Visual Studio 2019 preview

[)roi(]

Executive Member
Joined
Apr 15, 2005
Messages
5,942
Preview 3 is FYI stable for the most part on macOS except for some glitches with the static analyser and coincidently syntax highlighting; which can be corrected with a simple closing/re-opening of the affected .cs file.
Plus point it's much faster to startup, and also feels speedier on the whole.
 

Johnatan56

Honorary Master
Joined
Aug 23, 2013
Messages
25,072
1.5 speed near required...

UI more "compressed" (is this a good feature?), search improved with fuzzy search, debugging has substantial performance improvement they say, and has better search of debug variables.
https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes-preview

Preview 2 had background update download.
Windows Mobile deployment no longer supported

And then other things.

Their most important upgrades seem to be performance improvements, which is nice. I wonder why it took them so long, should have been a moderately easy thing if you can get up to 50% improvements? Seems weird.

EDIT:
Notice performance improvements now that the Visual Studio editor will limit the impact of auxiliary components on typing performance. Particularly, it will auto-cancel any long-running, nonessential operations when typing.
And that's an example of how it does it. Understand now.

And Xamarin forms people should be quite happy:
 

[)roi(]

Executive Member
Joined
Apr 15, 2005
Messages
5,942
FYI, no update has been released for macOS as yet.
Current preview build is 8.0 build 1805
VSmacOS.png
 

[)roi(]

Executive Member
Joined
Apr 15, 2005
Messages
5,942
C# 8.0
FYI VS2019 also includes C# 8.0, and here's a summary of those languages features.

Compiler assisted null reference checks
Either enable at the project level, or per file with the following annotation at the top
C#:
#nullable enable
Asynchronous streams
Similar idea to IEnumerable, except that you can now await for data and process as it arrives in a continuous type of stream. IAsyncEnumerable, remainder of the syntax is the same as used by standard async computes using await, async, Task syntax.

Range syntax for collection types
C#:
foreach (var x in xs[1..3]) {
  ...
}
Recursive pattern matching in a switch statement using tuples.
C#:
switch (a, b, c) {
  case (string ax, null, null): return ...; 
  case (null, null, string cx): return ...;
}
Switch statement expressions;
Syntactic sugar for recursive pattern matching, which works essentially quite similar to a ternary style expression:
C#:
return (a, b, c) switch {
  (string ax, null, null) => ...,
  (null, null, string cx) => ...
};
Default interface methods
1 implementation across all types that implement the interface.

 
Last edited:

[)roi(]

Executive Member
Joined
Apr 15, 2005
Messages
5,942
VS2019 Preview 3 for macOS has been released, however support for C# 8.0 is still an issue because mono does not support C# 8.0 as yet. Progress is lagging quite bit behind the Windows release schedule.
 
Last edited:

Spacerat

Senior Member
Joined
Jul 29, 2015
Messages
882
Not sure I 'get' the need for deconstructors? Except of course if those members are non-public
 

[)roi(]

Executive Member
Joined
Apr 15, 2005
Messages
5,942
Not sure I 'get' the need for deconstructors? Except of course if those members are non-public
The Deconstruct methods are valuable part of advanced pattern matching including the unwrapping of associated values, in a similar way to discriminated union types in Haskell, F#, Swift and Scala.

C# pattern matching with switch & Deconstructors
In the example Microsoft provided -- they are using the Deconstruct method in the Point class, to automatically control what element values of the instance that we switch over are made available for enhanced pattern matching.

This btw is very similar to how it's done in Haskell, F#, Swift and Scala (except I assess it to be arguably not quite as powerful as Haskell or Swift). This Deconstructor method approach is however quite unique to C#, so I'll need some time to properly weigh up my opinion; I could be wrong because the way it's done in F# is really good.

C#:
public class Point
{
  public int X { get; }
  public int Y { get; }

  public Point(int x, int y) => (X, Y) = (x, y);

  public void Deconstruct(out int x, out int y) =>
      (x, y) = (X, Y);
}

static string Quadrant(Point p) => p switch
{
  (0, 0) => "origin",
  (var x, var y) when x > 0 && y > 0 => "Quadrant 1",
  (var x, var y) when x < 0 && y > 0 => "Quadrant 2",
  (var x, var y) when x < 0 && y < 0 => "Quadrant 3",
  (var x, var y) when x > 0 && y < 0 => "Quadrant 4",
  (var x, var y) => "on a border",
  _ => "unknown"
}
Long standing point of contention between F# & C# language features
F# has had this advanced style of pattern matching and automatically deconstruction for quite a long time. So for me it's a really welcoming and overdue change that naturally will need a lot of experimentation for anyone who is unfamiliar with this concept to appreciate it.

Just know it's a powerful feature, and worth the time spent getting to know it.

Here's a code example without pattern matching and deconstruction:
C#:
public static Validation<L, R2> ApplyR<L, R, R2>(this Validation<L, R> @this, Validation<L, Func<R, R2>> f) {
  switch ((a: f.IsSuccess, b: @this.IsSuccess)) {
    case var t when t.And(true, true):
      return f.FlatMap(g => @this.MapR(x => g(x)));
    case var t when t.And(false, false):
      f.fail.AddRange(@this.fail);
      return Fail<L, R2>(f.fail);
    case var t when t.First(false):
      return Fail<L, R2>(f.fail);
    default:
      return Fail<L, R2>(@this.fail);
  }
}
Versus switch expressions and enhanced pattern matching;
C#:
public static Validation<L, R2> ApplyR<L, R, R2>(this Validation<L, R> @this, Validation<L, Func<R, R2>> f) => (@this, f) switch {
  (var lhs, var rhs) when lhs.IsSuccess && rhs.IsSuccess => rhs.FlatMap(g => lhs.MapR(x => g(x))),
  (var lhs, var rhs) when lhs.IsFail && rhs.IsFail => rhs.fail.AddRange(lhs.fail); return Fail<L, R2>(rhs.fail), 
  (_, var rhs) when rhs.IsFail => Fail<L, R2>(rhs.fail),
  (var lhs, _) when lhs.IsFail => Fail<L, R2>(lhs.fail)
}
I couldn't syntactically verify my code (re issues with mono support for C# 8); but it should be pretty close.
 
Last edited:

DrJohnZoidberg

Honorary Master
Joined
Jul 24, 2006
Messages
21,240
Seeing a few crashes quite regularly with 2019 so far. Both 2015&2017 been very solid in comparison. Hopefully they address these quickly.
 

[)roi(]

Executive Member
Joined
Apr 15, 2005
Messages
5,942
Seeing a few crashes quite regularly with 2019 so far. Both 2015&2017 been very solid in comparison. Hopefully they address these quickly.
I can't talk for VS2019 on Windows, but on macOS I have logged 20+ bugs since preview 2, of which approximately half related to crashes and performance.
Microsoft's team has been very quick to engage and to submit fixes; and even though it's a preview release, I already see some significant performance improvements over VS2017.
 
Top