The future of modern application development with .NET | BRK213
![The future of modern application development with .NET | BRK213 The future of modern application development with .NET | BRK213](/pic/the_future_of_modern_application_development_with_net_brk213/Mkt5MjhFdDNneTA_.jpeg)
[Music] hi i'm scott hunter director of program management for.net in this session you're going to see some of the awesome new things we've been working on for net six so you can build cutting edge applications that target any operating system with the best of performance and productivity dot net is a modern open source development platform for building many types of applications for many operating systems and devices with net six you can use multiple languages editors and libraries to build for web mobile desktop gaming iot and a whole lot more dotnet makes you more productive building feature-rich applications for any type for any device with great performance today i'm going to show you how you can build apps for the future with net but first i'd like to highlight some of the big accomplishments we've made with the community the.net ecosystem has seen some significant growth in the last few years there are now over five million monthly active developers in the visual studio family of tools dot net core has ranked number one two years in a row as the most loved framework on the stack overflow developer survey cloud native computing foundation cncf tracks the highest velocity projects on all github they measure this by the rate pull of requests and issues come in and how many are accepted the.net repo has been consistently in the top 30 since 2016 and is currently listed as the number one most active org c-sharp is the top five language on github an indicator of a healthy open source ecosystem and.net contributors are extremely proud of their work on performance asp.net core ranks at the top of the
industry tech and power benchmarks an independent open source set of web performance benchmarks that measure dozens of languages and application frameworks all of this is possible because of open source collaboration here you can see the tekken power performance comparison with java and node.js better performance leads to lower compute costs and dotnet gets better every release dotnet 5's web framework asp.net core is over 10 times faster than node.js in the grpc server performance is faster than go c plus plus and java i mentioned over 5 million monthly active.net developers all up in visual
studio but we're also continuing to see some great adoption of our latest releases of.net in the first six months of release dot net core 3.1 had 3 million downloads and it was the fastest adopted version of.net at the time i can now say that in the first six months of release of.net 5 has 3.6 million downloads and is the fastest adopted version of dotnet yet we hear from a lot of customers that they are moving to.net 5 because the
value and performance it brings over any other version to date so why dot net 5 applications built with dot net 5 can be deployed side by side on windows mac or linux with or without containers allowing you the ultimate deployment flexibility we continue to make significant performance improvements up and down the stack so that native client apps and cloud web apps perform excellent you can also reduce infrastructure cost and hosting costs particularly on linux dotnet and beyond is where we are making investments in the platform in the open with the help of the community this includes modern innovative languages and apis which make it the logical choice for any dot-net application going forward to help you we're building the.net upgrade assistant it helps you modernize older.net framework code bases it's a command line tool that gives you step-by-step instructions for upgrading to the latest versions of.net it will analyze nuget packages and understand where your dependencies are it gives you recommendations and fixes for project files configuration and source code to help you incrementally upgrade at your own pace multiple project types are supported including asp.net
mvc web apps windows forms wpf desktop apps and console apps and libraries and additional types like asp.net web forms are coming later the net upgrade assistant is in preview and it's open source and accepting contributions we're targeting release for net six in november but we're seeing customers use it very successfully today and i encourage you to give it a try now let's talk about where we're headed our vision for one.net is to simplify the platform and choices for dotnet developers and provide a single stack that supports the best breed solutions for all modern workloads in.net 6 we'll finish the unification of.net by bringing in the aot workloads that are supported by the mono runtime to bring one unified sdk base class libraries and tool chain we'll provide a native cross-platform framework for building apps for ios android macos and windows with a single codebase as an evolution of xamarin we will also continue investing in the cross-platform web ui stack by expanding on the capabilities of blazer we're also making it much simpler to build cloud-native apps and we'll continue investing in performance not only at runtime but also at build time so you can build and debug any app quickly and iterately here are some of the big areas of investment in dot net six i'm going to demo some of these in a minute but i want to call out that there are a lot of improvements so we're making with the open source community up and down the stack c sharp 10 is the next version of the language that will release with dot net 6. going
forward releases of c sharp will align with the releases of dot net c sharp tim has a strong focus on simplification features like global usings file scope namespaces remove much of the boilerplate code that you must write today there are also a lot of small productivity features that are all about improving the clarity and simplicity of your code net 6 will enable you to build cross-platform native mobile and desktop applications with a single code base with net multi-platform app ui or net maui blazer is expanding to support native device capabilities particularly important for desktop scenarios we're making it faster to build web apis with minimal code perfect for applications built for the cloud dotnet 6 will support more device targets and single file deployments for windows with up to fifty percent smaller size we have the productivity enhancements like hot reload for all project types and of course more performance improvements in the runtime in dot net six one of the areas we're focused on for better performance was entity framework core we aspired to be one of the best performing data access layers dapper for example a lightweight.net micro orm gave us lots of inspiration for this performance effort i'm super happy to report that ef core performance is now 70 percent better on the tech and power fortunes benchmark and the memory allocations have been reduced significantly up to 43 percent a lot of this is due to performance work in the dot net six run time but ef core six itself is also 31 faster in query performance these tests were done in house on the same hardware as tech and power similar results should be reflected on the next round of tekken power benchmarks for the fortunes test which includes database access now let's talk about what we're doing to make it faster for you to build for the cloud net six we're building upon c-sharp top-level programs to provide you with a lightweight way to build asp.net web apis with minimal code no usings no class definitions needed this is an easy way to build apis that can immediately take advantage of cloud scale without all the ceremony and boilerplate code of traditional controller style web apis and when your project starts to get too big we'll provide tooling to automatically convert these to asp.net
mvc controllers it's just another option for quickly building apis that don't need all the bells and whistles of controllers and startup classes and they'll be part of.net 6. let's jump into a demo i am super excited to show you asp.net minimal apis we first introduced webapism.net back in 2012 with the web api project built on top of mvc which uses controllers routing attributes conventions dependency injection and more to let you build enterprise class apis on.net
and we've carried all that technology forward to net six but we see a new trend around lightweight apis and small microservices and some new frameworks like express and node luminant php fast api and python make these super easy to build minimal apis we want to enable you to build the same lightweight apis using the same asp.net that you know and trust with less configuration and a path to upgrade to controller apis if needed to do this we're using a bunch of new technologies look at this application using top-level programs there is no class or main it's just code using a lambda i can write the function inline next to my route and if i run this you can see that my three line application can return hello world to the browser we think these new lightweight apis are going to make it easier for you to build microservices we think it's going to be make it easier for new people to learn and build their first apis and net so i'm super excited about this but i want to take this to the next level and show you a real api so let me go back to visual studio here we are back in visual studio and in this case i've got three api projects my minimal web api project hosted in azure uh that powers the rest of the demos you'll see today i've got my mvc web api project here as well and i've got an express application written in node let's start off with the mvc web api and you're going to see it's got a bunch of files startup.cs program.cs and it's got its weathercontroller.cs let's dive into the
weather controller and you're going to see these apis are based on classes that then have methods with attributes on them great for building lots of apis but if i just want to build one api i can go look at something like the express application here and look it's very concise down to 37 lines of code to build a single api gets right to the point now if we move over to the new asp.net minimal api you're going to see it's even smaller and more concise than the express application 30 lines of code and this is because we're using new features like top-level programs global using lambdas to really reduce the amount of ceremony you have to do to write a single api this kind of technology is great for building microservices and simple apis now as i looked at this i uh i wanted to compare all the technologies to each other and so what i've got down here is i've got a notepad file and i've kind of kept a tally of how much code you have to write so the mvc web apis that's really if you want to build a lot of apis that requires about 138 lines of code to get started the node express api uses 37 lines of code and amazingly enough you know.net uh minimal apis are only 30 lines of code and this is just showing you we're applying these new technologies to make it faster and easier for you to build great app so here we are back in visual studio and now what i want to do is run my app locally to make sure it works here we go and you can see it's pulling the weather back and so i've got a successful api using asp.net minimal api is running
now the next thing i want to do is switch back to visual studio and what i want to do is i want to publish this application to azure for the rest of the demos that you see today so i'm going to click publish we'll select azure and we'll select app service linux go let me create a new one i'm going to change my name just to minimal weather um i've got a hosting plan already set up for me i will select that press create here there we go it's creating my app service now i'm going to click next and i'm actually going to deploy using github actions using ci cd and click finish what happens now is when i commit my app it will do a ci cd flow to publish it i can switch to my repo and you can see all the steps have happened to publish my app to azure and now i can actually go and open my browser tab here and this shows the minimal api that we built running in azure and we will use this for the rest of demos today we've been shipping the first previews of.net multi-platform app ui that we announced a year ago at build 2020. dotnet maui is the evolution of xamarin forms designed to help you deliver high performance cross-platform native desktop and mobile apps all from a single code base in preview 4 that released today you can now use visual studio to build.net maui apps dotnet maui under the hood uses technologies out there today for building native apps on windows with wind ui mac catalyst for mac os and of course ios and android dot net maui abstracts all those frameworks into a single framework built on.net six
dot net maui on windows will support win ui and project reunion allowing these apps to use all the newest native features on supported versions of windows 10. that means you can build all these apps for any device from a single code base and project system instead of learning different stacks and languages for each you can now just use one language one set of libraries and one ui stack for all of them and that includes desktop and mobile operating systems windows mac os ios and android it will release as part of.net 6 in november you can watch the progress and he'll contribute on github in the.net maui
repo let me show you a demo of.net maui in action dotnet 6 brings consistent experiences from all project types to don and maui including the command line in this case we're going to create a new maui app with net new maui we're going to name it build maui now from here i could run if i wanted to dotnetrestor.netbuild.netrun but i want to show you how we can build an optimized experience for building cross-platform applications with visual studio so let me launch visual studio here dotnet maui targets ios android mac and windows and so what we're going to do here is take the single project here we're going to set this to startup project here and then what i want to do is i'm going to go to the debug menu here and we click that again drop that down and i'm select the framework that i want to run and i'm going to select android here and that means when i run the application it's going to actually run the application on my android emulator on the right here so let's get this started um one of our goals with maui was to give you a single project for building all your applications so you can focus more on your application and less on the specific targets of your application it all starts with the start.cs file
this is very similar to what we do with asp.net today this is where you configure all of the things for your application in this case we've set on we want xamarin forms compatibility we set our default application we're going to set our font right here and if i'm using third-party libraries i would configure them here as well maybe i'm going to use dependency injection i want to share something across my application i would put that here as well and so that's kind of the way we've copied that experience from asp.net over here now we have these folders android ios mac catalyst and we have the win ui three down here and this is where you write your platform specific code we also have a resource folder inside of that we put your fonts your images your app icon your startup screen all in one place and so here the application application is booting up in my emulator and what i'm going to do is i'm going to go and click the counter here and see it's at number five and i'm going to show you how to reload i can actually change either my xaml or my c-sharp and press save and as soon as i do the application updates immediately this helps with your productivity quite a bit now this is a semi-simple application let's use a more complex example and show you how we can do platform specific light up with net maui so here i am in visual studio with my weather application and you're going to see in that as i run it here it's a win ui native windows application but i've done a few things differently here if you look in my configure services i've added some new services i've added a tray icon for putting a tray icon on windows i've added notifications for native notifications and a tree icon for mac now if i go and show my main page here you can see i've what i've done is set up app actions this allows me to put a context menu when you right click on the app icon where you can put some menu items in here and make it do some other options i've also added a tray icon too and so what happens here if you click on the tree icon we'll send a notification on the platform that you're on with that data so if i look here i can right click here my new context menu showing up right here in my applications it's showing native ui hookup here's my tree icon i can click it and there you go you can see as soon as i did that a notification popped up in windows it's just showing how you can do these native light ups across all the platforms now i can't just show you just windows dot melody's cross platform let's go to my mac and i'll show you a couple of couple other options here you go i've got my same ui and same code running on ios mac os and android if i resize the mac os application you see it resizes dynamically like you would expect if i click the icon you see those same menu items there you saw before and then if i click the icon at the very top you'll get that notification directly on your mac so this is showing you how we can do this cross platform line up but still give you these native options with net maui all using the same ui blazer has become a very popular way to write dot-net web apps in fact it's one of the fastest growing workloads in dot-net today we first supported blazer on the server then in the browser with webassembly and now we're extending it again so you can write blazer desktop apps in.net 6. this means you can create hybrid client apps which combine web and native ui together in a single native client application it's primarily targeted at web developers that want to provide a rich client and offline experience for their users laser hybrid apps is built on top of.net maui it relies on the ui stack for a native application container and native controls should you want to use them blazer desktop apps have full access to the machine you can do things like call native apis access the file system write multi-threaded applications all with the high performance and optimal memory consumption you get with net you can't do this with pure web technologies although it will run anywhere our primary focus for blazer is on supporting rich desktop scenarios on windows and mac let's see what we can do with blazer desktop apps blazer makes it easy to build rich modern web ui here's our weather app implemented as a web app using just html css and net the web app has a nice responsive layout so it looks good on mobile devices as well as desktop screens we can see the current weather and local weather forecasts we can also check out the weather from other locations here's the weather in south korea here we can also change the settings of the app to switch from imperial units to metric units and automatically gets applied to the entire application now all of the client-side interactivity in this app is implemented using reusable blazer components that work in any modern web browser using just the open web the app calls our azure hosted minimal weather api to get all of its weather data by pairing blazer with an asp.net core server you can
build full stack web apps with just.net our weather app can still use some improvements the list of weather stations on the right hand side looks a bit plain in.net 6 we can quickly make changes to our asp.net core
and blazer apps using net hot reload here's the component that displays each weather station as you can see right now it's got some simple markup let's update the styles for this stack box class save that it gets automatically applied looks nice now let's also add some markup here in order to better lay out the text and maybe add an icon save that with dotnet hot reload our changes get applied to the running app without losing any app state blazer makes building web apps with net fast and fun but sometimes you need more than what the web platform offers by combining blazer with net maui you can reuse your existing web ui logic and web development skills to build cross-platform native apps that can take advantage of the underlying platform dotnet maui comes with a built-in blazer web view control that you can use to add existing blazer components to any dotnet maui app this means we can take our blazer components from our weather app and embed them into the.net maui app without having to change anything here is our weather app running on as a native desktop app on windows it looks the same and has exactly the same functionality using the same blazer.net code blazer components hosted in.net maui run directly in the dot-net process this means they run fast and have full access to the native capabilities of the device through the net platform for example we can reuse the same system tray integration that you saw previously and trigger native platform notifications because this blazer app is running inside a.net maui app it can run on other platforms too let's switch over to my mac to see how blazer desktop app can run cross-platform alright here is our blazer weather app running as a native mac app as you can see it's got the same look and feel it's got the same functionality if we check out the weather in south korea we can do that there it is and it looks and feels the same because it's the same code that we ran in the windows app and also on the web the app also has native integration so we can show the little.net bot up in the menu we can click him and trigger a native notification by building our app as a blazer hybrid app with net maui we get the best of dot net the best of the web and the best of the native platform we're working on a bunch of productivity improvements everywhere that will help you build and debug your apps much quicker we commonly refer to this as the inner loop it includes build time performance improvements in both the cli as well as visual studio you can see here that build times have significantly improved as compared to net five we're also working on bringing hot reload technology to all project types that means you can make ui and code changes while running and your app will immediately refresh no more depth by a thousand f5s no more start stop make a change repeat there's no process restart state is maintained and you can optionally attach the debugger it's really the evolution of edit continue we're very committed to making.net 6 the
most productive development platform for you no matter what type of app you are building let's dive deeper into how hot reload will improve your productivity for this demo i have two apps to show you first let's start with the wpf app running on the right hand side this is a net 6 app called boyds a game of live simulator and you can see many shapes moving around with net hot reload we can now change the game logic while the app is running to do that we're going to press this brand new button now let's go ahead and make a change to the app and see how it works i didn't build the app so i'm not sure what changes to make but let's go ahead and change speed limit that seems like it's going to do something so i'm going to go ahead and change that how about we add 10 to it now i'm going to apply the change and as you can see the behavior of the game is changing right away i'm going to undo that i'm going to make a different change i'm going to make a change to the percentage to move towards home not quite sure that's going to do let me just add 0.1 to that and again i'm going to apply the changes and now you see a dramatic change in the app without having to restart it while it's fun to show you an app like this i now want to go back to our weather app and show you some edits that should feel like real world situations let's switch over to our weather app here's the weather app you've seen in the other demos as you know this is a net maui desktop application and here too we can apply code changes while the app is running so first i'm going to look at the wind indicator i expected some simulation code had been added to make the indicator move let's go and see go ahead and see what happened and you go look at the code and find there's a to do here instead of stopping the application i'm just going to go ahead and add the code that i would have expected to be here i'm going to add a get direction which gives me some random directions i'm going to change it so it applies the direction icon and i'm going to apply those changes the indicator starts to move for favorites i'm going to go ahead and click that button and it seems like something is missing here as well so let's go look at the view model well i have some properties here but it seems like i have no logic to load the data let's make a change that's needed now i could have typed this but just to save us some time i'm going to paste the code in it should have been here and you can see we have a constructor an async method a private method all this can be applied to the running app by hitting the apply code changes switching back i can go ahead and switch the home screen switch back to favorites and now i see the data but i see one last bug it's only loading redmond let's go take a look ah yes would be easy to miss it should be an i instead of zero i'm going to apply those code changes and navigate back and forth there we go and now we get all the data we expect now with this app it usually could take 15 to 20 seconds to restart the application and it's a small demo app but with hot reload we were able to make all these changes without having to restart the app a single time imagine how much time it will save you net 6 preview 4 is available today and previews drop every month until we release in november i highly encourage you to download and check it out i showed you.net maui laser desktop apps and some of the work we're doing to make cloud native development much simpler but there's also a ton of other great features coming download.net 6 preview 4 and try it out today and finally i'm excited to announce that dot net conf 2021 will be november 9th through the 11th where we will launch dot net six like always this three day virtual event will go deep into all the things you can do with net we'll have tons of sessions from the product teams at microsoft as well as the community keep an eye out for the call for content opening soon and learn more at dotnetconf.net save the date
i hope i got you excited about.net 6 today if you want to learn more please visit our blog to read all about the preview for release we also have a longer on-demand video for you with a lot more demos that you should watch and please attend our ask the expert session thank you for watching you
2021-05-28 23:11