 Welcome to .NETConf 2018. My name is Scott Hunter, and I'm a Program Manager at Microsoft on the .NET platform, and I've got Mads with me as well, who works on our languages, and I've got Miguel with me as well, who works on Xamarin Mobile. So we are super excited to be here today. We have a lot of really cool material. I'm going to talk about .NET that we're going to have Mads come on and talk about C-Sharp for a little bit, and then Miguel is going to come in and talk about Xamarin and Mono and some other cool stuff that we're working on. So to kick it off, let's roll into this thing. Okay. So .NET, one of the monitors we've had the last couple of years is, you can build any type of application in .NET, whether it's a desktop application, a web application, a Cloud application, mobile gaming. We just recently, earlier this year, added IoT support for .NET Core, and AI support for the .NET platform. So we think that no matter what you want to build, you can build it with .NET. Really excited about the growth of .NET. People always ask me, hey, should I invest in .NET? Is it still growing? One million new developers in the last year, and so .NET is a super healthy platform and super growing. The other one is .NET Core. We shipped this a couple of years ago. It's starting to mature in the .NET Core 20 wave. We've got over half a million developers every day writing code in .NET Core. So we're super happy about that. The last time I spoke to everybody was around the build conference, and we were showing some previews of .NET Core 2.1. We shipped this at the end of May, and you can get it today. I wanted to quickly highlight some of the big things that happened in .NET Core 2.1. You'll see here, we've always cared about performance in .NET, and we want to prove to our customers that .NET is a super fast platform. So there's a public benchmark, which means we don't run the benchmark, and we've been working to continue to make .NET work better in all phases of that benchmark. So you can see here on the slides, plain text we're up 15 percent, JSON we're up 18 percent, data access we're up 147 percent, and the last one probably matters the most, because most applications actually are some form of rendering and some form of data access, and you can see these huge improvements in all of these. I actually have the benchmark running in my browser, and I wanted to highlight a few things in that benchmark real quick. This is round 16, the latest round of the benchmark, and I'm going to go to plain text. What's interesting about plain text, if I scroll down here, you can see that we have ASP.NET Core at round number 11 in this, but you're going to notice that the top players here are all roughly at the exact same percentile. We're at 99 percentile compared to 100 percentile. The Delta between ASP.NET Core and the top item is roughly less than a 150,000 requests per second. So everybody at the top is super fast and worth the top of that. Now, what I said before is great, plain text, who writes a plain text application, not many people. If I go to fortunes, this is the craziest form of the demo, where are the benchmark. It's got web rendering, it's got data access, it's calling endpoints, and you're going to see ASP.NET is once again in roughly the top 10 in this, and this is where you saw that data growth, that making our data performance grow, is what helped us catapult.NET into here. So the thing I want you to know is if you're a.NET developer and you're using ASP.NET Core, you're using one of the fastest web frameworks on the planet, and that's something we care about and we'll keep working on. So back to the slides. What were the major features? I'm just going to quickly go through those. We had a bunch of cool features in.NET Core, 2.1. One was global tools. This is the ability to actually install command line tools right from NuGet. You can, if you're familiar with NPM, you could do NPM install-g, that would globally install a tool. Now we have a.NET version of that same thing. So you can write a cross-platform.NET Core console application and install it with a one-line command on any device. We rewrote the socket layer in.NET, which is why you saw some of those performance numbers you saw in those benchmarks. But we did this focus on the server, we also focused on the client. We rewrote the HP client to be way faster. It's about 10 times faster in.NET Core 2.1. We continue to make.NET Core 2.1 more compatible with existing.NET. So there's a Windows compatibility NuGet package. If you're an EF Core customer, my favorite feature here is we added lazy loading. It's one of the most popular features in EF that our customers are using. It wasn't in Core. Once again, we're feedback driven. We took that feedback, added it to EF Core 2.1. Then in ASP.NET Core, there's been this huge push this year in making all websites HTTPS. So ASP.NET Core is HTTPS by default. For the first time ever, we've allowed you to take web UI and actually put it into a library and NuGet package so you can share it across multiple applications. We have this really cool feature called HTTP Client Factory which I'll do a demo in a second. We also brought one of our beloved frameworks from the.NET Framework World, SignalR is now available in Core as well. So let's jump here and I'll talk about one more thing real quick. SignalR, as it RTM for Core in 2.1. We also know that SignalR, we always have customers call us and say, how do I build a really highly scalable SignalR? We have an Azure service that you can run your SignalR back end in inside of Azure, and you can just drag sliders to auto-scale that application, and we do all the heavy lifting for you. What I'm super excited to announce today is, on September 24th at Ignite, we're going to GA the service. So let's move on and let's do a quick demo of.NET Core 2.1. So I mentioned this thing called HTTP Client Factory, and we always talk about it, and it sometimes I think confuses people because it's kind of hard to see feature, and I'm going to try to dumb it down today and make it really simple for everybody to see. So I've got an application here, and it's got an API, and I'm just using the typical values controller that we give you in a default application. So it's not doing anything crazy. I've got to get method that just returns a value. So it's not reusable, but it's going to highlight the point. So let's take this API and let's start it. So I will just go over here, and we'll say start without debugging, and the API is going to boot up and run. Now I've got a simple app, and I'm sure this app is very simple similar to what you, the customer is probably doing, and it's got this index HTML, CSHTML, and inside of it, it makes an API call. Let me just take that away. It makes an API call, so it's not anything crazy, and you have all probably done this, and this is great. I can run this application, and so basically whenever the index page is hit, it makes an API call to that API, and I'm sure your applications do something like this, whether it's a desktop app, a web app, and you see this works great. Now, I'm going to change things a little bit. Let me go back to my API, and I wrote this cool piece of code here. It's called a random failure middleware, and so what it's going to do, it's going to make my app fail randomly, and I want to do that because we know networks go up and down, connections go up and down, and you should make apps resilient to this. So I'm just going to add this middleware, random failure middleware, and if I scroll here, you'll see that all it does is, looks to see if a random value is there, and it throws an exception sometimes, and sometimes it doesn't throw an exception. So let's restart this app. We'll restart the app with that middleware enabled, and now if I go back to my client app, I assume everybody's going to expect what's going to happen is if I'm back in my client app, it's going to start failing occasionally. There you go. I refresh the page, it fails. So what would you do as a customer? In the past, what you would do is you would go into your index page and you would probably write some retry logic around this. Now, that's great. You'd write this retry logic everywhere you call an API, maybe you only harden one API or another API, or maybe you write a wrapper around HP Client that does this for you. So what we've done in 2.1 is we've added the ability for you to set policies. So I can say add, let's go down here, HTTP Client, and what I can do here is I can create a HP Client factory. What this means is I can create an HP Client and give it a bunch of rules, and with those rules, I can define a bunch of stuff that you can do. So look here, add HP Client, API, and then I say add transit error policy. So I'm saying, hey, I want to have an error policy, and what I do say here is I say policy retry async6, which basically means if you fail, try again six times. Now, you can set multiples of these, there's a whole bunch of these that are available, but by setting that line there, I've now got a set of rules that are applied, and then in my code, instead of creating an HP Client this way, I can go and ask the factory to do that for me. Client, factory, create Client, oops, I'm going to give it that name that you saw earlier, API, so it will look that up. And then so everywhere in my code, instead of just newing up an HP Client, now I say factory give me one called this, and those rules are applied to it. So I can now run this code again, and now even with that API throwing exceptions, this app is not going to crash because it's complaining that the app is still running. Now we're going to run it again here, and I can refresh this as many times as I want. It'll never crash because I've set that policy. And so this is a great feature you should be using in your apps today, set your policies, don't write code around all these APIs, and it's part of our work to make microservices better in .NET. So let's move on, and let's talk about 2.2. So just this morning, we shipped preview 2 of .NET Core 2.2. It's available today, you can grab it right now. And let's talk about some of the big highlights or the themes that we have in the 2.2 wave. One of these things is we want to make web APIs easier to build. Every app, whether it's a web app or a mobile app or a desktop app is probably calling some APIs. We know this is an important area, so we want to make it easier for you to build APIs and to build clients that can call those APIs. You just saw with the HTTP client work we did in 2.1, we make it easier to call APIs. Microservices, we hear microservices all the time and so there's a bunch of work we're doing to make microservice better in .NET. And we're always continuing performance, whether it's building your applications or running your applications, those are the big themes. So let's go over some of the major features. Multi-tier JIT compilation. This is the ability for us to quickly JIT your application to get it running and then to notice if it's actually hitting the same method a lot of times, maybe we should JIT it again and make a faster version of it. SQL connection with token auth. This is support for the first time to actually grab a token to talk to your SQL server from Active Directory. So you don't ever have to have any client credentials that are put in configuration files or anything like that. EF Core, one of my first two features are my favorites. Cosmos DB. We know that there's non-relational databases out there and you might want to use the same EF programming model to talk to a relational database or a non-relational database. So you can use Azure Cosmos right from EF Core today with Tutu. Spatial extensions. This has been one of the most requested features for EF, which is spatial in this case is types for geographic locations. If you want to have a longitude latitude, because maybe when you want to look at somebody's GPS coordinates and figure out where they are and run queries in a database, we've not had those in EF or .NET Core, and so those are both there. We have a feature in EF where you can actually point an existing database and it will make you a model. Now it has the ability to actually take views in that database and expose them in the model for you as well. So those are some pretty awesome features in EF Core. ASP.NET Core, they did all our templates with the latest versions of web frameworks, whether it's Bootstrap or Angular. Web API is one of my favorites. One of the common things that I get when I go talk to customers is how do I secure an API? And so for the first time ever with Tutu, I think it will be in preview three, we're going to have the ability for you to actually secure your API endpoints in the box. We've got support for HTTP2. That's been a longer quest. Health checks. Glyn Condron is going to do some demos later in .NET Conf around this. This is the ability, if you're building microservices, to have checks in your apps or in your microservice to actually report whether it's healthy or not. Especially if you're running in a container infrastructure, that's really important. We've got a SignalR Java client. So if you want to use SignalR from Java, we've got support for that. So that's some of the major features. Let's do a quick demo of .NET Core 2.1. So what I've got here for that is, there's a demo I showed at Build where we were showing how you actually can do diagnostics on APIs. And so let me do that here. So as we think about microservices, things that we think about in the team is we, how do we make APIs better? One of those things we want to do is we want to integrate Swagger into the API so it actually gives metadata that we can use to provide a richer experience of building clients or debugging. The other one that I always have fun showing people is, this is an API app. And so if I just run it in Visual Studio, you get this great experience of 404 because there's no web in there. And so we really want to fix this debugger experience that we have. So we actually have a global tool that will ship at some point in the 2.2 wave. And I'm going to switch my browser to be that global tool. As I was saying before, .NET 2.0 brought these global tools, and now you can actually, we're using them ourselves. So now when I run this application, let's go look at the app real quick. I've got a controller here with a bunch of people in it. These people are obviously ranked in order, me, Hanselman and Guthrie. And it just returns people. How would I test this API? Now that I've changed my browser to the REPL, here we are in a command prompt and I can just do an LS and that's going to show me the controllers I have. You can see people and values. If I want to get the people, I can just say get people. And if you look here, that goes and makes that request. You can see it brings Hunter, Hanselman and Guthrie. I can do things like CD into people. And then I can just do a get. So we let you move around like you might want to. Great for testing APIs. I can make changes. Just come back here, re-run those APIs. Maybe you like UI. I can jump right in here. Go into the UI. Maybe I want to add another person here. Just type in .NETConf. And I can basically say try it out. That'll send that request. And I should be able here to say get people again. And there's .NETConf. So the goal here is to make it easier to build and debug APIs with .NET Core. So let's close out of that. And let's move on. Okay. .NET Core 3 update. At build, I was talking about .NET Core 2. When we first started it, it supported web and cloud applications. At build, we talked about adding desktop applications, IoT applications and AI applications. So we vastly are expanding the workload that we can actually build on top of .NET Core. So let's briefly recap what happened to build. I talked about adding support for WinForms and WPF to .NET Core. So for the first time ever, you can build desktop applications on .NET Core. We support a bunch of the other features that Windows talked about, XAML Islands. This allows your apps to host any of the newer controls, the UWP controls in your WinFormer WPF apps. We talked about XAML controls. This is taking some of the most common UWP controls and wrapping up into WinForm and WPF controls. You can just drag in. So if you want a modern browser or modern media player and high DPI fixes. We've talked about adding support for all the Windows 10 APIs into .NET Core 3. And finally, one of the bigger things we talked about that I'm really excited about is being able to do what we call the App Bundler. This is build a standalone .NET executable that does not require anything on the machine at all. Simple self-contained XE that can run your applications. So really cool feature. A lot of people ask why? Why did you move these old frameworks onto .NET Core? First off, they're awesome frameworks. The big thing is you get all the .NET Core benefits side by side. You can run multiple versions of WinForms at WPF on the machine. They won't break your applications. If you install a new version of WinForms, you can run multiple applications that use WinForms. You can have a machine global or an app local version of those frameworks. If you want to copy WinForms into your app, it'll use the one in your app. If you want to use a global one, you can use a global one. You get some of the core runtime and API improvements. This is because .NET Core is side by side, we can make API fixes that we couldn't make in .NET Framework and so you get those. And you get our really cool new version of CS Proj that you can edit by hand. So you get a bunch of these features. Now, let's talk about what's happened since Build. WinForms is now available in our Nightly Builds. I don't recommend running our Nightly Builds, but if you go to github.com.net.core-stk, you can download the latest SDK from there. And once you do, you can actually just type .NET new WinForms. Visual Studio, the latest versions of Visual Studio now support building and debugging these WinForm desktop applications directly in the IDE. We don't have support for the designers yet. That'll be coming soon, but this is the next step. And then finally, we plan to publish a preview, a public preview, later this year in Non-Nightly Builds, so you can start trying to move your applications to .NET Core for the desktop. And so let's do a quick demo of that. So what I'm going to do is just go to Command Prompt here and let's make there WinForms, CD WinForms, and I'm going to do something new, .NET new WinForms. Let's just drill in here and show that. Just like you can do .NET new web, .NET new console, well now I can do .NET new WinForms. And after I do that, I can run .NET Run. There you go. And so I built a WinForm application in just a few seconds, typed a few commands, and boom I'm in here and it's running. So what else can I do here? So let's load VS up, and what I'll do is I will come over here and I will open a new project and let's go into that folder and open that CS project. Yeah, yeah, yeah. I might have to launch a new version of VS but let's try it real quick. Boom. Okay, so you saw I could run it right in VS but I want to show this is a core project. So if I go and edit my CS project, there's the .NET SDK, WinXZ is the output type, .NET core 3.0, it's referencing the desktop UI. Let's see what you can actually do here. I'm going to go into the form editor here and I can come in here and say label one dot text equals .NETconf rocks. There you go. And to prove that the debugger works I can come over here to the break point in here. So I've got a WinForms .NET core project, my debugger works, I get full IntelliSense in the project. So we're making a lot of progress in this and as I said if you want it is available in the nightly builds. You can just run over here and install the 3.0 installer from the GitHub page and try this yourself if you want. But full WinForms support. While we're sitting here talking about WinForms I want to show one more thing about WinForms. At build I showed that we had one of the reasons you might want to run your WinForms application in .NET core. So let's look at that real quick. This is the sample that I ran at the build conference. At this point when we built this you kind of had to hand build projects you didn't have that support I just showed before you could .NET new and all that kind of stuff. But I just want to re-show this to highlight one of the things that was really cool about that demo and this is a simple app that we ran. Let's do this. And all it does is it takes a folder and it goes and iterates over that folder and you can see it's showing me how much stuff is in those folders. And you can see this completed in 755 milliseconds. I also have a version of that that runs on core so I can take that same folder and run that again 282 milliseconds. I'll bring these together so you can see the big thing here is the core version of this you can see you ran about three times faster two to three times faster than the .NET framework version of this. And this is because as I said before we've had time to go through and take some of the APIs and improve them and with .NET Core because it's completely side by side we can not worry about compatibility the same way we have to do with .NET framework. With .NET framework we're afraid to touch those APIs because it's installed on billions of machines and we can't break anybody's applications. With .NET Core the customer makes the choice the developer makes the choice which version of .NET Core they want to use and Windows updates and updates to the machine won't break those applications. But you can see we made a bunch of progress I can now build these things from the command line I can open, edit, debug inside a visual studio and you see that I get a big performance boost in these applications because they're running on core. As I said before we hope to have a public preview later this year where you can try these bits without running a nightly and hopefully we'll get designer support in that time frame as well I don't know but we're working on it. That's an update on .NET Core 3. Let's talk about Blazor. Blazor is a cool project that we started showing it seems like about a year ago and the version we showed a year ago was we called it an experimental project and what it does is it allows you to build client-side web UI in .NET. We have lots of customers that might feel more familiar with C-Sharp than they are with JavaScript they might not want to learn the JavaScript framework of the year Angular React View and they want to take advantage of the stability and consistency of .NET so that's what Blazor was built about Blazor used a technology called WebAssembly to basically load .NET into the browser so we can actually run a version of .NET live in the browser and so you have a client running both in the browser on the client and on the server and there's some cool benefits because you're running .NET you're going to get native performance you can share types between your client and server and it requires nothing on the browser there's no extension or plug-in or whatever it just works and so we've been showing this for a couple months now I have a slide update on this what we've done the most popular part about Blazor is the programming model is just amazing I can be in some HTML and I can just call C-Sharp I can use the skills that I already have so we decided that we're going to take that programming model and we're going to move it into ASP.NET Core 3 but it's a little different than the experimental version in that the experimental version we're running .NET Core in the browser the version that we're going to first start with that will be in ASP.NET Core 3 is going to run that same code on the server the programming model is exactly the same so you don't have to change any code I'll actually build a Blazor app in a second and it doesn't matter whether it runs on the client of the server you get this awesome programming model and so the cool thing is as we do this you're going to be able to take advantage of this and then in the future with .NET that we're really happy with running in WebAssembly you'll be able to just change a few lines of code and your app will then start running with .NET in the client and you'll even more performance so I'm super happy to announce this and let's do a quick demo of this because this is cool tech so what I've got here is I'm going to close these out and I'm going to open up my Blazor app here and I was sitting around we were talking about how to show this tech and so I wanted to take a common application programming thing that somebody might do today with some JavaScript and show you how you would rewrite that in C sharp and get the same benefit so this is a web page and you can see here in my web page I have an image of a bot I've got a button here and on click it calls change image change image is JavaScript it's right here it goes and grabs that bot element so it goes and finds the the bot here, the image tag and it then goes and grabs the source attribute for that and it says hey if that's got a 1 in it replace it with a 2 if it's got a 2 in it replace it with a 1 and so let's run this and see what this does still have my API client there running so let's turn this off back to my browser there we go run this again and so this is going to come up and if I click on this my bot's going to going to switch and do that all client side it's super super cool what would that look like if you want to rewrite that in C sharp let's try that so what we'll do is we'll go back to that index and first thing I want to do is I need to write some C sharp in this web page so I'll create a functions block and inside of this block I can write whatever C sharp that I want to write so first off we need a URL so let's do string image URL equals and let's just grab this image we already have here that's great we'll stick that in there and now I need a method that will change this image I need to do that same swap we were doing in javascript so I'll do void change image and let's just write it pretty much the same way as you saw in the javascript if image URL contains a one and what I would do is I would set image URL equals image URL dot replace and I'll replace the one with two and else image URL equals image URL dot replace and we'll just replace the two with a one so I'm basically every time the URL we call this method we look to see what URL we have if it's got a one in we change it to a two if it's got a two in it we change it to a one and we do that because in my app I've got two images over here a dot in it about one and a two so here's just you know regular C sharp now what I would do is come up here and where I have this this here I'd erase this and we'll just say at image URL typical razor C sharp syntax and where it gets kind of cool here is on this on click where I'm calling this javascript function I will now add an at sign here to call the C sharp function remove those two and now I've actually rewritten the same app that would normally use javascript to change the two images to now use blazer to change those two images so let's run this again it's complaining a little bit cancel the build there we go I screwed up somewhere didn't I yes left a semicolon off once again same experience you would expect in visual studio you can see it and now that same app that I just showed before using a javascript function now does the exact same thing all written in C sharp so I think this programming model is amazing if your web developer building razor based ASP net core application today you're going to love this if you want to write your javascript in C sharp or javascript kinds of stuff in C sharp you now can do that and as I said it'll be a core feature of ASP net core three and the ability to run down the client using web assembly will be something that we continue to work on as we move forward as well so let's jump back over here and we'll move on so the next thing we want to talk about is machine learning and .net the last couple of years you can read the news you hear about machine learning and AI hot topics and at build we talked about wanting to build your own custom models a great example of this one of the demos we showed at build is our github repo has tons of issues filed in it and we looked to see if we could go build a bot that would actually go and take those issues and automatically classify them to the right areas and in our case we had plenty of data so we took all the data that our team has done by manually moving those things over the years ran it through something so we took that data and we then pushed it into ML.net to build a model and then we ran that model and so I want to announce today we have ML.net 0.5 you can get it right here it's the latest preview of those ML.net bits that we shipped at build continuing to improve this make it better make it easier for you to use please go out and try this today you can see that we've shipped 4 previews there's a whole bunch of areas F-sharp support you can see here we've got a bunch of samples including that sample that github classifier is now up there and we're continuing to embrace this technology big thing about ML.net that I like to tell customers as well is this tech is built on tried and true AI that we use inside of Microsoft so if you're using Office or Bing you're likely using some of the same tech that ML.net is based on and so tomorrow we're going to kick off with a session on machine learning and artificial intelligence I think with Onkit and Caesar so you should be excited about that and next I want to bring in Mads to come talk about the new enhancements we have coming in C-sharp let's go on sir thank you Scott it's going great let me just get the power point up here so if you don't know Mads, Mads works on managed languages at Microsoft whether it be C-sharp, VB or F-sharp and today he's here to basically show us some of the enhancements that we have coming in new C-sharp all right so first let's talk a little bit about what we already did so we went through no less than a slew of different versions of C-sharp over the last year or so we have what we call point releases 172 and 173 looks like a slide show went away there let's try again now I gave away my little unicorn there so essentially this idea with the point releases was to get better at giving you value right away rather than bulk everything up for releases that are further between but we also had some concrete value around span of T and efficiency at the low level that we wanted to get in quicker and so there are three sort of loose themes in these point releases that's the safe efficient code which underlies some of the improvements we got on tech and power for instance and then there's just general more freedom allowing you to do more things that were forbidden before various ways of abbreviating things the usual like little juicy features and we're going to talk a little bit more about the safe efficient code in a minute but of course we also want to talk about C-sharp 8 the main theme here is it's going to be magical I will if the demo gods prevail I will show a little of that as well and in this in this keynote so but let's start out with the with the dotnet with the C-sharp seven one seven two and seven three and this theme about safe and efficient so if you writing sort of low level code you're trying to get performance you essentially have to navigate between the Silla and Cariptus that is garbage collection can be you know provide an overhead and unpredictability of your performance at the low level but if you try to avoid garbage collection and you start using structs and things that aren't allocated then you run the risk of copying too much and so essentially we ratcheted up our toolbox for dealing with navigating these waters and so Odysseus here is going to use span of T to navigate between the two dangers that lurk on either side of the straight here and there are several language features that are there to enhance the span of T experience and help out with how you can write a struct based and array based code without getting too much copying so let's go and have a look at span of T we are having a lot of flicker here there we go so span is essentially this idea that while .NET has arrays and they're sort of an efficiently packed chunk of memory there's no easy way to refer to other chunks of memory so to speak there's no window on to contiguous memory the way that you might want so here I have a simple program that creates an array initializes it and writes it out and to show what span is about let's just quickly look at array and we see that there are some new extension methods here related to the span features in .NET framework so there's as span for instance here so I can take the array and somehow get it as a span so it should not click out of percent of you sorry guy not in percent of you okay I don't know why it's showing that thing so tell me where to back up from this always happens I thought something else was going to go wrong today and it still may for now back in I'm back in visual studio you guys are probably just looking at you're looking at mobile development with Miguel de Casse or something like that so give me a thumbs up when the code is up in the meantime I can talk a little bit about span of t without visuals so the idea is that you can essentially a span is essentially a view onto an array or a contiguous expansive memory and so when you have a span it's just like an array but it lets you view the bits of maybe some other array or of well here we go again of other memory that may be allocated in other ways so there we are I don't know how much you caught here let's just start from scratch with the demo I have an array I'm initializing it I'm writing out the elements now I want to do some fun with spans so let's take the array and look at the new extension methods there I can say as span what I get back is the new type that is called span of t in this case I have a span of int so let's write that out just so it's clear though I'm normally a varlover I have a span here what you can do with the span now over the array is well obviously if I initialize the array let's have a look at what the elements in the span are let's try to run the program see what the demo gods say to that oh there we go so you can see that even though I even though I created the span from the array the modifications to the array down here are visible through the span so it's really like a window onto the same memory and why is it interesting to see the same memory well maybe I don't want to see all of it maybe I want to just for instance take a slice of it and rather than copying all the elements that are in a given slice let's say from element 3 and 5 elements maybe instead of doing that I want to just get a window onto it and not actually modify a create a new array which is an expensive thing so here we have a slice and if we write out the elements of the slice it should show just the just the elements that we're looking at but the slice is still and it's still a view onto the original array if I go into the into the slice and say assign to the second element let's assign 100 in there and we write out the elements of the original span say then you can see that the fifth or whatever it is the sixth element of the span has been modified as well because we're again we're still modifying the same memory that's a very useful feature there are concerns about this whole oh I can modify a memory through other objects if you don't like people modifying it but you just want them watching along you can use a read-only span which is just a version of the type that does not allow assignment so you can see my modification through the slice here is now disallowed so I can pass these out to others they can observe my changes but they can't affect changes of their own so that's it for span let's return to the slide deck here and injecting so and talk about black holes or rather the scourge that has been writing object-oriented programming for many years which is null reference exceptions you can probably come up with others but I think this is the big one and we decided in C-sharp 8 as part of the magic unicorn thing to help you avoid null reference exceptions so this is where let's actually, let's skip the slides and see if the demo works this is where things currently they came together last minute here so we'll have a look and see if this works out so first of all I have a program here I have a good friend Miguel de Caza who has no middle name he assures me and now I'm trying to get the length of his middle name by calling the get length of middle name here and simply returning the length of his middle name well this looks like a noxious code but it's going to, through a null reference exception because I'm getting his middle name he doesn't have a middle name so it's probably going to be null that's going to give us a null reference exception well who's really to blame here let's go look at the person class that we created here we can see that we have first name and middle name and the last name but in the constructor that I use for Miguel I'm only initializing the first and the last name if only I had a feature that could tell me whoa they either tell me whoa you're not initializing the middle name it could be null or a feature that I could tell well I want it to be null well that's what the nullable feature is about and the way I turn it on is to use an attribute called non-null types and when I put that on the module you can see that I get a warning on the on the person class here a warning saying you did not sorry let's see if we can hover over the warning here saying you did not initialize a non-null a non-null field so I can either go initialize it middle name equals null I want it to be null and then that warning goes away but I get another warning saying you're putting null into middle name so what's going on here why can't I put null into a reference type well I can't because with the new feature turned on reference types are no longer able to be null without warning you get a warning whenever you put null in there if you want to have null you have to explicitly ask for it so I can go here and explicitly ask for middle name to be nullable I put a question mark on a string just like you can today on an int or whatever I'm saying I want a nullable string here might be null you see the warning goes away everything's hunkidory with my person class but now when I go back to my program and I have rightly specified that middle names might be null then I get a warning here saying hey you may be the referencing a null and so now the feature is helping me push around where can there be nulls where can't there be a nulls and making me correct my code so what are ways I could correct this well maybe you know I maybe I have an if statement just think how you would solve this bug if you got it from like say a bug report from a customer where you had the null reference exception in production so we can say if p dot middle name is null this is how you should always check for nulls now that you have pattern matching because it does not unlike using double equals it does not use overloaded equals operators it always just checks for null if p dot middle name is null well then let's return zero for instance now look at what happens with the warning the warning down here goes away because the compiler does a flow analysis and it knows that by the time it gets to this line of code p dot middle name is no longer null so it's kind of like definite assignment that it tracks the possible values of variables throughout the body of the method and make sure that when you dereference things null is not one of the possible features there or possible values there so that's a quick glimpse at nullable reference types and with that I want to bring it back to my friend Miguel de Acasa who is waiting in the wings to tell us a little bit more about Samoring. Thank you very much Miguel. Thank you Mads. Well this is one of my favorite features in C sharp it's a gift of the gods in this case really a gift of Mads. So anyways well Mads and the team of course so I so I'm going to talk today about mobile development and what we're doing there for you are we're here to give you so here's a little bit of an agenda I want to talk a little bit about our community and what we're doing to improve our community and open source contributions we'll talk about the Android platform the Apple platforms Samoring forms and a couple of interesting things that are happening coming up so the so first off we really I really want to thank everybody that has been that has been engaging with us in our open source effort as you can see it has been an incredible year for open source contributions to the project we only open source these three pieces the Android support iOS and form support when Microsoft acquired Samoring two years ago so so these numbers actually reflect that all time is just the last two years when we open sourced but as you can see it's you know there's a tremendous amount of energy and people contributing to the effort and in mono's case you have to give in mind that these only counts changes to mono but we are now pulling about the about 35% of the code now it comes directly from core effects and core CLR so so it's even a larger effort now up until this point you have to realize that when you work with this systems you know we came from a you know we came from a from the Unix universe and we're very comfortable using e-max and vi make files and every you know thing that we do in the Unix world but it wasn't particularly easy for newcomers to come in it's an organic system something that we've grown over the years and it's easy if you were part of the community but if you're a newcomer it was difficult so over the years we've tried different things in fact this effort an effort to improve the way and the easiness of building mono started many years ago my friend Jonathan Chambers who now works at Unity I found the first commit in 2007 he contributed this change that allowed mono to be built with visual studio as opposed to this linux tool chain that was ported to windows that had an emulation layer for windows and so on so this effort started in 2007 and it actually took us 11 years to get every piece in place but the outcome is fantastic so these days this is how you can build mono on windows you just get visual studio installed the first three lines that are just getting your gate checkout download your mono and get all the modules in place and then the next two lines the first one builds a mono runtime for windows it generates a native x8664 binary and then the second line builds all of the class library so everything that you need mscorlib, system, systemxml and so on you see a little flag there called net4x and that means that in this particular scenario you are requesting to build the .NET 4.x compatible set of APIs there's a lot more there's the android APIs, the monotouch APIs and so on but what is really interesting about this is that every assembly now that is part of mono can be built it comes with a CS approach which means that you can open it on visual studio you can build it, we do the dependency tracking so what is really nice about that is that you don't need to worry about the chain of compilation we will get all the dependencies for you and these are just some of the other targets that you can use and we support everything under the earth now we really hope that this is going to make it a lot easier for people to come in and contribute fixes and improvements in tuning to all the mobile SDKs so just a refresher of what we're doing we are big into the native into delivering a native experience for users so that means native user interfaces so when you create a button we want to get a native button so that it behaves the way that user expects it has proper animations proper colors, proper behaviors, touches and so on integrates with accessibility and so on and every other feature in the US we want to give you all the APIs that the platform offers so on Android everything that Google offers on the Apple platforms everything that Apple offers so from .NET you can use everything in there and of course we want to give you the best performance possible and the last thing that we do is we try very hard we work very hard we work very hard to deliver to you same day support for these platforms this past summer we just shipped our Android support for Android Pi so we have a blog post we have samples we have everything to get just started with Android Pi and you know you can always count on that in fact today is a special day and we'll get to that in a second now at build this year I announced the support for accelerated Android emulation on windows that work with Hyper-V so some of you had to choose between Hyper-V and Hyper-V and this year we work with Google and we got the support for Hyper-V integrated into the Google emulator I closed my session with this beautiful artwork that said if you get the windows April update you're going to be super happy today is just the regular windows update that you can use and you should be happy and I say you should because because Spectre happened and some of the mitigations are allowed for Spectre slow down the Android emulation now the good news is that if you're trying some of the alpha the previews of windows this is addressed and we're going to have this for those of you affected by the Spectre things we're going to address that later this year now so now we wanted to not only improve the Android experience the emulator experience but we wanted to improve your life when you're building applications and we've essentially looked at the problem from two perspectives first how can we improve the build times for you when you're building a new project then you have to rebuild everything from scratch you do a git checkout and you get to build the whole thing so we spent a lot of time optimizing every step in the pipeline and we're looking at every step in the pipeline of how we can fix this optimization some of those are profiling some of those are being smart about the things that we do and some of those are upgrading some of the tooling capabilities some of them are skipping steps some of them are avoiding slow processes so we're doing a lot of work in that area and we also want to improve your day to day developer experience so every time that you make a change and you want to test it we want you to get your code up on the screen as quickly as possible now just so you get a feeling for how this works this is not even a complete picture but it gives you an idea when you build an android application you need to package at the end a zip file that contains everything here that is blue all the blue balls there those need to be shipped into the APK now when you and your sources essentially the user c-sharp code or your XAML sources they need to be compiled into your c-sharp executable then we need to inspect it we need to extract some java data then we need to compile that data then we need to compile it to the native android format and so on so this is a series of steps that some of them are serialized and cannot be parallelized and they can take a long time so we've been tuning this pipeline so if you have native libraries java-native libraries well we got to extract those things if you have native C libraries well we also got to extract those things and we got to get them out so what is that thing doing at the bottom of the screen so we need to get all of those pieces in place and we've been tuning this so let me share with you some of the improvements that we're doing right now so this is we're comparing of a fairly large application this is called the smart hotel 360 app smart hotel 360 is a sample app that we showed at connect last year and it's a relatively large application 25,000 lines of c-sharp that's really not the large part is for the sake of expedience and getting this quickly and having a lot of capabilities this application actually consumes 99 NuGet packages and this has everything under the sun dotnet standard libraries support libraries from Google Google Play services, Azure services SKEA for rendering images native code everything really and 32 XAML screens and we cut down the build times from 2 minutes and 15 seconds to 57 seconds so I'm very excited about what we're doing in terms of improving the build times and all of this happens at the SDK level so there's really no changes necessary on visual studio at the MS build level so all of this all of these improvements will continue to trickle out now the other thing that we realized is that when you're building forms applications and in particular if you're using dotnet standard for your share business logic oh okay if you're using dotnet standard for your share business logic you don't need to run this process the whole time right you don't need to run the whole thing and repackage everything so we've added a mode called fast development mode and now we have a prototype a proof of concept and this proof of concept that today exists in a separate form we're going to integrate all of that work directly into our build system and let me share with you what it is the proof of concept is Xamarin Android Lite and it gives you the ability of rebuilding your forms application and deploy and run so you make a change at 5 and it's showing a device 3 seconds it's 2.9 seconds but I want it to be I want it to run it up so it's about 3 seconds from a change to visualizing it directly on your device so I'm looking forward to delivering all of these to you folks later this year now as you know today is an exciting day IUS 12 is very likely going to be announced and we expect that it will be coming soon so good news we have your IUS 12 support ready ready in store and when I say IUS 12 I really mean the entire set of Apple updates that are coming today which we suspect is IOS, TVOS, macOS and watchOS so that's what we internally call it Xcode 10 because it's the whole platform but most people think of this as IUS 12 so we're ready for you today and start spicing up your apps if you haven't started yet there's a couple of really interesting things so probably the one that my favorite feature in my opinion is is support for shortcuts this is a way that your application can participate in scripting in the system so what is interesting is that now your apps can essentially describe an action of something that the user did and you can in this action you need to provide it to the operating system it's called you donate the action the intent and when you donate this thing this becomes searchable in Siri it becomes something that you can invoke from Siri but also and this is the software programmer in me you can actually script your application so they can become part of this new shortcut application shipping IUS 12 where you can script your app and call into your app and we'll talk a little bit more about how you can do this because you essentially need to you give it a URL sort of like deep linking and then the operating system will call into your app and we have something for you there then also ARKit 2 is coming out we have some good samples for you and what is very nice about ARKit 2 is that now it can detect physical objects those objects it can remember spaces and you can have shared virtual spaces that is a little bit interesting we have great samples for you to try out our IDE has been updated to support these new capabilities ARKit also supports detection of existing objects so if you have a collection of objects that you want to scan or pictures of those you can build those in and you've probably seen those demos in the past six months of people building recognizers for little cards or bills so all of this is built with this technology there's a new networking stack this is an amazing networking stack that was introduced if you're trying to do networking today it's incredibly painful because you have to know too much about how the mobile world works disconnections, changing networks paths and so on this is a callback based system here's a little taste of what it looks like but it's very interesting because not only does it handle connections, it also handles TLS security for you it handles Bonjour and you also get state transitions so if your phone drops, if there's a connection change if you connect to a new network you'll handle it there there's a lot more to try on iOS 12 today so you should check it out let me talk about perhaps one of the most exciting things that we've been working in the past for you it's called the Forms Shell Xamarin Forms is a write once run anywhere framework and we give you a lot of tools we give you every control that you can imagine, layout, function and the problem sometimes is that as a new developer trying to create an app it feels like opening a bag of Lego with no instructions and now you get to build a universe so it is not unusual for, you know, you have a goal you have an objective, you want to build an app for your particular problem and before you can get there, you need to figure out navigation, top menus nesting how to handle the back button how to do searches there's all these things and all we've given you we gave you the pieces, we gave you all the pieces but we didn't really give you any guidance or how to stitch these things up and even if you do, sometimes people make mistakes it becomes bug reports and things that you need to fix and so on or you create, so you end up creating user interfaces that look like this beautiful UIs with italics where they really don't belong these ideas for UIs that make no sense imagine, this is how I envision my first email program, it obviously makes no sense I don't know what there's a slider there I don't know what there's an arrow maybe it's something that you felt looked good on the screen or you saw it somewhere or an emoji and then this other control you misuse the control, instead of having buttons you use this thing inbox and trash, it's a selector it's not a button, there's no action and then at some point in a dream you had this dream where you thought you know what would be cool if you could control the number of lines in the preview and you make it 12, nothing makes any sense your users look at this and actually you just move on, you go back to something a lot simpler like being a physics nuclear researcher so we wanted to address this and what we did is we built this thing called the shell and the shell it's an opinionated type that sets up gives you a skeleton, a foundation where you plug in the pieces of your application you fill in the content that we take care of the layout of everything else we give you a consistent look and feel you can style it you can style it either the hard way with XAML or you can style it with CSS and we take care of the rest but we also take care of deep linking so every page in the shell has a URL assigned to it and we can launch the application directly into one of these pages so by building all of these functionality in there we're taking a lot of the pain away from you and we're handling it ourselves we also handle material we get a material look and feel on Android which usually involves a lot of moving pieces and things that you have to do so I'm just going to give you a quick taste of shell this is what it looks like this is a very simple application where we're trying to emulate with shell the Google Play Store so you can see here that the different elements of this app and if you look at the source code it's actually trivial, it's very very simple all of these UIs are very simple to build and I'll give you a little bit of that in a second this is what it looks like on Android and the same app and here you'll notice that we decided to use a green tint and the tint is shared across all of the pages to give it a look a consistent look to your app we have the same thing for iOS oddly it's the Android Play Store running on iOS but you get the idea and this is what it looks like on XAML as you can see you have a new top level container shell and then you have to fill in some of the details you can see some pieces there like the fly out header that's what would come up if you press that hamburger button then you have your content for the bottom menu bar and the items that go inside the most basic app that you can build is this one this is the simplest version of something that you can have it has just one homepage and in this particular example local colon homepage is actually a type in your app what's being rendered inside if you want to add tabs all you have to do is add two sections very simple the icon the sections and what you wanted them to be called if you wanted to add these nested tabs you can add them very easily just by adding the shell content there and finally these are all the idioms that are already baked into the system that you can build with shell today the other thing that we're adding to forms are two things that have been highly requested the first one is the collection view so we know that you wanted to have a collection view that goes beyond just lists but we took this opportunity with collection view to actually make something of general purpose so these can actually replace of list view and it has some much better performance characteristics than the old list view and that is because we no longer use sales sales were a great concept were a great concept but they didn't really map well to the way that it worked it was very expensive so now you just use regular views and data templates so some of the view that had concerns about the performance of list view were addressing those problems with collection view by essentially eliminating the concepts of sales and going with views and data templates let me give you a little bit of a taste of collection view on this video that I have here I hope I can get it to play yep there it goes so this is a new UI that previously was not possible to build with the built-in capabilities or it would have been very difficult to get this sort of UI you can have custom layouts which I'm sure a lot of you would be very excited to use and the other element is the other thing is many of you want to have a carousel view and it turns out that a carousel view is just a collection view with some good defaults in place so this is a sample just of the carousel view which again is just a collection view but it has been customized to have this particular behavior I want to close with two last pieces I didn't want to get into every single feature of forms there's just too many this year at the beginning we launched the project F100 which was 100 paper cuts and 100 small features that our community wanted we work with the community and we've got a lot of those it's a very very long list of every single little piece keep those things coming hopefully we'll get that to project F200 and so on and finally we're about to launch our Xamarin Essentials is the companion to forms that allows you to abstract if you don't want to use the native APIs and you just want to have a nice cross-platform abstractions it is our cross-platform abstraction for the non-UI pieces so you should give it a shot and that's it for the mobile segment I would like to bring my friends Mads and Scott back to stage awesome so I think in closing this is just the start of .NETConf 2018 there's a bunch of awesome sessions coming up over the next couple of days we were just looking at the schedule over there a second ago and James on your team has got a mobile session coming up Dan Roth's got an ASP.NET Core update coming as well he's got a Blazer update coming Diego on the team's got a EF update coming as well we already talked about tomorrow we're going to kick off with some AI with Ankit and Caesar's got a section on that as well so there's tons of awesome I'm skipping plenty of people as well kinder's got an update on what productivity features we have in Visual Studio so there's tons of great content coming the next day or two or three so please watch that content and enjoy being a .NET developer I guess Mads has a session we're going to break here and I don't know how botched up my demos came out online but fingers crossed if anything didn't go out you can see them there and also on Friday I have a session on Retro.NET so if you're despite the fact that I work with UIs I still love the command line so if you're into that sort of thing I'll have something on Friday for you lots of awesome .NET content coming we have awesome .NET features coming out .NET Core 2.2 .NET Core 3.0 next year there's just lots of good stuff so anyways if you're a .NET developer please check it all out thank you for watching