Saturday, December 12, 2020

[ADVENT 2020] F# Advent 2020: Revisiting Windows Forms and WPF in .NET 5.0 and hello F# 5.0

 Hi my blog readers!

This year, we have lots of exciting news on .NET Core land: the release of .NET 5.0 and also the release of new language version of F# and C#!

Last year, I discuss about how to write F# code with project support for Windows Forms/WPF in .NET Core 3.1. Also I'll showcase simple sample of latest new F# 5.0 features. What about .NET 5.0?

PS: .NET 5.0 is not .NET Framework. It is actually .NET Core version 5.0, and Microsoft describe as no "Core" branding from .NET 5.0 going forward. See also https://docs.microsoft.com/en-us/dotnet/core/dotnet-five#net-50-doesnt-replace-net-framework

In .NET 5.0, the TFM can be explicitly stated to support the underlying OS. Current .NET Core 3.1 has no TFM with OS directly (so does previous version before 3.1.

This means that in .NET 5.0 and later we should not use .NET Core Windows desktop SDK support like we have in .NET Core 3.1 and 3.0. 

As always, since .NET Core 3.0 and until 5.0, there's no default project template support to create Windows Forms/WPF project using F#. However, we can still code Windows Forms/WPF using the same way we use in my previous F# Advent 2019 blog. Again, with a twist of .NET 5.0 feature 😊

Now let's look at how the current .NET 5.0 create WinForms/WPF project from dotnet CLI.

To create a new winforms app project in .NET 5.0, we can use the same template in 3.1 like this example:

dotnet new winforms -n CSNet50Winforms

Let's look at the generated C# project: 

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net5.0-windows</TargetFramework>
    <UseWindowsForms>true</UseWindowsForms>
  </PropertyGroup>

</Project>

We can see we have two noticeable features:

  1. We can just use default "Microsoft.NET.Sdk" SDK
  2. TFM is set to .NET 5.0 with Windows

Now we apply this to F# project, with the same model of SDK and the TFM as above. The fact is that this SDK project model alongside with TFM is actually not enforcing programming language support, because although Winforms and WPF provides C# and VB support, we can also use the same SDK for F# as well.

Let's start create new console project using F#, and name it FSWindowsDesktop using dotnet CLI:

dotnet new console -n FSWindowsDesktop -lang F#

We'll have this fsproj generated:


Change TFM from net5.0 to net5.0-windows, and also change OutputType to WinExe.

The output type change is important, because we have to explicitly tell the project that we have to mark the resulting Exe as Windows executable to run the app for Windows. See also the technical reason about this change since .NET 5.0: https://docs.microsoft.com/en-us/dotnet/core/compatibility/windows-forms/5.0/automatically-infer-winexe-output-type

Open the Program.fs, then copy the content of Program.fs from my previous .NET Core 3.1, then build it using dotnet build: (I name the project to same FSWindowsDesktop)

dotnet build FSWindowsDesktop\FSWindowsDesktop.fsproj

Then run it! Or, you can also compile and run the project using "dotnet run".

Now we're going to update the code to use one of the cool F# 5.0 features, the string interpolation!

Update the program.fs to be like this:


Note line 21, we use string interpolation to represent the name of the field/variable. It is useful, because now we could avoid compile error especially when the field/variable name changed!

I added the size of the mainForm, because we need to see the title of the form changed to include the string interpolation, combined with other new feature of "nameof". Run the code and we will see this WinForms window:


There you have Windows Forms project in F#! 
This time, with demo of string interpolation, and with also a sample of new "nameof" feature to include the name of the variable/module/symbol as string expression.

As always, the full code is available on my GitHub repo: https://github.com/eriawan/netcore-fsharp-sample

Enjoy and celebrate F# Advent 2020 and happy holiday and Merry Christmas, everyone! 





Wednesday, May 20, 2020

Speaking at DevOps Indonesia joint collaboration with MUGI Jakarta: DevOps Indonesia May 2020 online meetup!

Hi my blog audiences!

If you have followed me last year, I have had collaboration with DevOps Indonesia meetup, now this month I have had another good collaboration with DevOps Indonesia.

On 19th May 2020, we collaborate on having joint collaboration, on behalf of DevOps Indonesia! We were having a wonderful teamwork!
This is the meetup link: https://www.meetup.com/DevOps-Indonesia/events/270642522/



I was participating as speaker to represent MUGI Jakarta, and also helping to give feedback on how the meetup should be, because this is MUGI Jakarta and DevOps Indonesia's first online meetup!

Here, we were using Zoom to host about 50 participants:


This is intriguing! Yes, I have had online remote speaking at Louisville meetup, but now I decided to record the video first and ask Mia and Wisnu from DevOps Indonesia to play the video during my session. This is necessary, because I was having unstable internet the day before the meetup.

There were 2 speakers, one is Gopesh Maindola, a Consulting Engineer from Palo Alto Networks, and then me. I'm proudly represent MUGI Jakarta! 😍

On this meetup, I presented "Adopting shift left and sift right in DevOps". I also gave more sample use cases using the proven best practices from Microsoft, the Azure Cloud design patterns and how Microsoft implements DevOps in its own organization.

First, we have opening from DevOps Indonesia. The team, Wisnu and Mia presenting DevOps Indoonesia meetup timeline:



This is me presenting in recorded video::



I gave use cases from Azure Docs page:



And another nice thing is the online meetup was live on Youtube!
You can watch the full session at: https://www.youtube.com/watch?v=OwqdIHlD0eo

Enjoy the recording video and welcome to "new normal"! 😊



Sunday, March 1, 2020

Representing as Microsoft MVP at DevCon Digital Economy Summit

Hi guys!
I'm humbly proud that I have participated at the DevCon Digital Economy Summit 2020 that hosted by Microsoft Indonesia!
This event is held at Ritz Carlton Hotel, Pacific Place, Jakarta.

I was part of MVP Indonesia team that helps Microsoft Indonesia to promote, spread the event information, and also taking care of special MVP Indonesia's booth.



We are sooo honored to have President of Indonesia, HM Joko Widodo and MS CEO, Satya Nadella!



Here's me and fellow MVPs (Andri Yadi), taking care of MS MVP Booth, answering any questions about software development, .NET, and Visual Studio:




And we (Andri Yadi, Agus Suparno, Adiityo) still had some fun taking pictures with MS Asia's Annie Matthew and MS Indonesia's Irving Hutagalung:



Yup, I'm glad that I could provide help for software developer communities thru this conference! 😉


Wednesday, January 22, 2020

Speaking and mentoring on Preparation of your first tech talk at Global Diversity CFP Day 2020 Jakarta

Hi my blog audiences!

Again, this year is a sweet-speaking-busy year! I mean positively busy speaking and sharing what I know but also sharing experiences! Now, I'm also mentoring! Sweeet!

Thanks to offer from Sarah Thiam, Microsoft APAC Developer Relation PM that asking me to help mentoring and speaking for this community meetup, Global Diversity CFP Day!

NOTE: CFP stands for Call For Paper, and it's a common term of open/available opportunity to submit your proposal paper for speaking talks.

To be honest, this is my second speaking about diversity in 2007. At that time I was speaking for small meetup group in Surabaya to empower women developers. This time, I'm not just speaking, I'm mentoring! 😊

Also thanks to Microsoft Indonesia for sharing and supporting its venue for this meetup! I am so grateful, folks!

This was the event announcement: (at https://bit.ly/gdcfpjkt2020)



Not just me, we also had an array of amazing community speakers like Galuh, Kiki, Imre Nagi Adrianti Rusli, Prabu Rangki, Hepiska Pranata.

First, we have opening speech from Kiki and Galuh:


In that photo, Galih explained about common speaking paper submission for call for paper opening. She also explained how to get/search for call for paper opportunity. Great tips!

Then I deliver how to prepare your first tech talk. Put it simply, don't be afraid to start submitting your proposal, guys!


I welcome noobies, of course! Because..



Therefore it's quite similar on how continuous integration and continuous deployment on DevOps works, THERE IS ALWAYS A CONTINUOUS IMPROVEMENTS 😊

I also deliver an analogy while at the same time presenting Azure DevOps conceptually:


Next, Prabu Rangky presented on how to deliver your speech and presentation effectively:


Full of cool tips!

Then we had cool presentation about How to ensure accessibility on your presentation, delivered by Adrianti Rusli:


Last but not least, we had cool presentation on how to do live demo for speaking, by Imre Nagi:



Next step is the real DO, the workshop!

The workshop was so amazing! All of the participants were eager and anxious to start wrting a speaking paper proposal:



Those participants were also encouraged to deliver 5-min talk, to ensure that they are actually doing it 😊

The event final moments are nicely done, we wrapped up in a freestyle photo session in front of Microsoft Indonesia receptionist desk 😉



That's it! 

PS: I always open to be invited for speaking for not just my own community, but also other communities especially for those communities promoting diversity like this!