Flatlogic Platform Updates: November 2021

Flatlogic Platform, also known as Web App Builder is gathering pace!. Yay! We have already 2570 applications generated, and that’s not the limit!

TypeScript added.

Migrations added.

GitHub integration included

Free 7-Day Trial Added

We keep on updating our Flatlogic Platform , a powerful tool for building fully working CRUD web applications with front-end, back-end, and database.

November was a productive month with four new releases.   Check out the highlights:

Quick Overview

Arbeit macht frei.

1. TypeScript Added

TypeScript is a well-known programming language that makes app development easily maintainable and faces fewer bugs while coding. Thanks to TypeScript you can add static typing to JavaScript to enhance developer productivity. TypeScript lends structure and safety to your app and simplifies the process of code writing. It assumes and adds the data types to variables and functions.

2. Migrations

When developing an application, a situation often arises when not only the program code changes but also the database. In order to change databases in a consistent way in all development environments, the migration mechanism is used.

Now you don’t need to delete your app data to change the database. It is a crucial step to providing hosting for your application and an integral part of the app production process.

3. GitHub Integration

Can we do without GitHub? No, no and no again.

Track all your changes made to the source code of the application. GitHub version control assists you in this keeping and synchronizing your edits to the code in the GitHub repository. Set it up in the settings of the curated project, tap to connect your GitHub account, save it.

4. 7-Day Trial Period Added

We are happy to share the option to test the Flatlogic platform for free. Get a free 7-day trial and test our service in full. Feel free to share your observations and expectations, if wanted.

If you need more information on how our platform works, read please Flatlogic Platform documentation. Every day we add more and more options to our Flatlogic platform and we strive to make it the best one, interviewing the customers and making it the place where all of its functions will be tested and fine-tuned. Click here to learn more about upcoming features, our Boss is sharing the list of some features from the roadmap.

That’s it for today!

Stay tuned for more updates from Flatlogic and subscribe to our socials! 

The post Flatlogic Platform Updates: November 2021 appeared first on Flatlogic Blog.

The Dew Review – C# 10 and .NET 6 – Modern Cross-Platform Development, 6th Ed (@packtpub) by Mark J. Price

I received an eBook review copy of this updated .NET resource by Mr. Price and wanted to provide some of my initial thoughts on the book. I have read previous editions of this book, reviewed the topics covered by this new edition, and read several of the sections in detail to get a sense of who could benefit from reading it and how it has been updated. I continue to be impressed by the quality, breadth, and depth of this book and the updates made for .NET 6 and C# 10.

Like my previous review of the fourth edition, I still recommend this book to several different types of developers:

New, aspiring developers – The book offers some great history on .NET development and lays a solid foundation for starting your development journey with Visual Studio, VS Code or VS for Mac. Language and framework fundamentals are explained and enhanced with useful exercises at the end of each chapter, reinforcing the concepts. Some basic development concepts/practices, such as inheritance and unit testing, are discussed in the early chapters.
Experienced .NET Framework developers new to .NET 6 – The chapters on new .NET 6 and ASP.NET Core features step through the changes and enhancements that were significant to each release. There is a section on porting apps from .NET Framework to .NET Core and .NET 6, discussing how this can be done and whether it should be done (hint: usually not).
Developers using older versions of C#. – There are sections on the features of each C# version, explaining how the language has evolved over the years with .NET.

The section on Entity Framework and EF Core is also a great intro to object-relational mapping (ORM) concepts for developers with little to no exposure to it.

I have really enjoyed this book so far. I’m looking forward to buying my own print copy to continue exploring it. For me, print is the best way to get the most out of this kind of programming book. Shorter books on specific topics can work better as eBooks, but I like to keep copies of large reference books on my desk to quickly flip to bookmarked pages. Check out the free Kindle sample here on Amazon. I think you’ll like what you read and will want to order a copy for yourself.

Finding Async Method Calls Missing Await

I’ve run into this issue not only when migrating legacy projects to use async/await in C# .NET, but even just day to day on greenfields projects. The issue I’m talking about involves code that looks like so :

static async Task Main(string[] args)
{
MyAsyncMethod(); // Oops I forgot to await this!
}

static async Task MyAsyncMethod()
{
await Task.Yield();
}

It can actually be much harder to diagnose than you may think. Due to the way async/await works in C#, your async method may not *always* be awaited. If the async method completes before it has a chance to wait, then your code will actually work much the same as you expect. I have had this happen often in development scenarios, only for things to break only in test. And the excuse of “but it worked on my machine” just doesn’t cut it anymore!

In recent versions of .NET and Visual Studio, there is now a warning that will show to tell you your async method is not awaited. It gives off the trademark green squiggle :

And you’ll receive a build warning with the text :

CS4014 Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the ‘await’ operator to the result of the call.

The problem with this is that the warning isn’t always immediately noticeable. On top of this, a junior developer may not take heed of the warning anyway.

What I prefer to do is add a line to my csproj that looks like so :

<PropertyGroup>
<WarningsAsErrors>CS4014;</WarningsAsErrors>
</PropertyGroup>

This means that every async method that is not awaited will actually stop the build entirely.

Disabling Errors By Line

But what if it’s one of those rare times you actually do want to fire and forget (Typically for desktop or console applications), but now you’ve just set up everything to blow up? Worse still the error will show if you are inside an async method calling a method that returns a Task, even if the called method is not itself async.

But we can disable this on a line by line basis like so :

static async Task Main(string[] args)
{
#pragma warning disable CS4014
MyAsyncMethod(); // I don’t want to wait this for whatever reason, it’s not even async!
#pragma warning restore CS4014
}

static Task MyAsyncMethod()
{
return Task.CompletedTask;
}

Non-Awaited Tasks With Results

Finally, the one thing I have not found a way around is like so :

static async Task Main(string[] args)
{
var result = MyAsyncMethodWithResult();
var newResult = result + 10;//Error because result is actually an integer.
}

static async Task MyAsyncMethodWithResult()
{
await Task.Yield();
return 0;
}

This code will actually blow up. The reason being that we expect the value of result to be an integer, but in this case because we did not await the method, it’s a task. But what if we pass the result to a method that doesn’t care about the type like so :

static async Task Main(string[] args)
{
var result = MyAsyncMethodWithResult();
DoSomethingWithAnObject(result);
}

static async Task MyAsyncMethodWithResult()
{
await Task.Yield();
return 0;
}

static void DoSomethingWithAnObject(object myObj)
{
}

This will not cause any compiler warnings or errors (But it will cause runtime errors depending on what DoSomethingWithAnObject does with the value).

Essentially, I found that the warning/error for non awaited tasks is not shown if you assign the value to a variable. This is even the case with Tasks that don’t return a result like so :

static async Task Main(string[] args)
{
var result = MyAsyncMethod(); // No error
}

static async Task MyAsyncMethod()
{
await Task.Yield();
}

I have searched high and low for a solution for this but most of the time it leads me to stack overflow answers that go along the lines of “Well, if you assigned the value you MIGHT actually want the Task as a fire and forget”. Which I agree with, but 9 times out of 10, is not going to be the case.

That being said, turning the compiler warnings to errors will catch most of the errors in your code, and the type check system should catch 99% of the rest. For everything else… “Well it worked on my machine”.

The post Finding Async Method Calls Missing Await appeared first on .NET Core Tutorials.

.NET Conf 2021 Recap – Videos, Slides, Demos, and More

.NET Conf 2021 was the largest .NET Conf ever with over 80 sessions from speakers around the globe! We want to give a huge THANK YOU to all who tuned in live, asked questions in our Twitter feed, and participated in our fun and games. The learning continues with community-run events happening thru the end of January so make sure to check those out. Also, watch the session replays and keep an eye on our conference GitHub repo where we are collecting all the slides and demos from our presenters.

If you participated in .NET Conf 2021, please give us your feedback about the event so we can improve in 2022.

On-Demand Recordings

We had a lot of awesome sessions from various teams and community experts that showed us all sorts of cool things we can build with .NET across platforms and devices. You can watch all of the sessions right now on the .NET YouTube or the new Microsoft Docs events hub.

What were your favorite sessions? Leave them in the comments below! I have so many favorites, but I loved the Productivity talk around Roslyn and AI with Mika:

I also recommend the C# 10 session with Mads and Dustin.

Explore Slides & Demo Code

All of our amazing speakers have been uploading their PowerPoint slide decks, source code, and more on the official .NET Conf 2021 GitHub page. Be sure to head over there to download all of the material from the event and don’t forget you can still grab digital swag as well!

.NET Podcasts App

We are happy to announce the release of .NET Podcast app, a sample application showcasing .NET 6, ASP.NET Core, Blazor, .NET MAUI, Azure Container Apps, and more from the .NET Conf 2021 keynote!

Grab the source code on GitHub and start exploring locally on your machine, or fork the repo and deploy to Azure with GitHub actions in a few easy steps.

Launch After Party Q&A on December 16th

On December 16, 2021 .NET Conf and Visual Studio 2022 launch event speakers and experts will be LIVE to answer all of your questions. Learn more about the recent launch of Visual Studio 2022 and .NET 6, including tips and tricks, new features with the latest releases, and connect with others in your community.

Register for the event today!

Local .NET Conf Events

The learning continues with community-run events happening thru the end of January so make sure to check those out.

Thanks again to everyone that made .NET Conf 2021 possible and we can’t wait for even more .NET Conf events in 2022!

The post .NET Conf 2021 Recap – Videos, Slides, Demos, and More appeared first on .NET Blog.

344: With Aaron Iker

Today I get the pleasure of talking with Aaron Iker. Aaron builds incredibly delightful bits and bobs of UI that give you the feeling of hey, I bet I could actually use this! And that’s exactly what Aaron wants you to do. He takes care to make sure the code is easy for you to use if you wish. This idea of taking somewhat practical-looking UI elements, like buttons, loaders, toggles, etc, and then making them do something unexpected and fun is a perfect fit for popularity on CodePen. Last year, Aaron occupied 10 spots in the Top 100! Aaron’s advice: keep challenging yourself.

Time Jumps

00:17 Guest introduction

01:13 Designing for usability

03:43 Sharing across multiple platforms

05:03 Are you interested in 3D?

05:54 Sponsor: Netlify

07:18 Where do you get inspiration?

08:58 Is this what you do professionally?

12:52 What do you reach for in tech tools?

15:35 What’s your process for creating?

19:36 Do you use other platforms?

23:47 Feedback differs on platforms

26:07 Any advice for people?

Sponsor: Netlify

Netlify is Jamstack hosting with all sorts of features to help make developing sites easier (have you seen Netlify Dev? You can run the whole platform locally) and deployed sites better. But Netlify is a big place! They do all sorts of community things like Jamstack Explorers, a whole learning platform for leveling up your Jamstack skills. Not to mention several YouTube channels loaded with learning and fun.

The post 344: With Aaron Iker appeared first on CodePen Blog.

GraphQL Subscriptions in ASP.NET Core

This post is about implementing Subscriptions in GraphQL. Subscriptions are a GraphQL feature that allows a server to send data to its clients when a specific event happens. Subscriptions are usually implemented with WebSockets. The subscription type is almost implemented like a query. Most cases subscriptions are raised through mutations, but subscriptions could also be raised through other backend systems.

First we need to implement a Subscription class, like this.

public class Subscription
{
[Subscribe]
public Link OnCreateLink([EventMessage] Link link) => link;
}

The Subscribe attribute will make the method support subscription. And Subscription works using WebSockets, so we need to add WebSocket also to the pipeline. Also we need to modify the Subscription type to the GraphQL server with the subscription storage. In this example, I am using in memory storage, you can use Redis as well. Here is the updated code.

builder.Services.AddGraphQLServer()
.AddQueryType<Query>()
.AddProjections()
.AddFiltering()
.AddSorting()
.AddMutationType<Mutation>()
.AddSubscriptionType<Subscription>()
.AddInMemorySubscriptions();

var app = builder.Build();
app.UseWebSockets();

And you can trigger the event using the ITopicEventSender instance which will be injected to the pipeline. We can modify the Mutation class – AddLink method like this.

public async Task<LinkOutput> AddLink(LinkInput linkInput,
[ScopedService] BookmarkDbContext bookmarkDbContext, [Service] ITopicEventSender sender)
{
if (string.IsNullOrEmpty(linkInput.Url))
{
throw new ArgumentNullException(nameof(linkInput.Url));
}

var link = new Link
{
Url = linkInput.Url,
Title = linkInput.Title,
Description = linkInput.Description,
ImageUrl = linkInput.ImageUrl,
CreatedOn = DateTime.UtcNow
};
bookmarkDbContext.Links.Add(link);
await bookmarkDbContext.SaveChangesAsync();
await sender.SendAsync(nameof(Subscription.OnCreateLink), link);
return new LinkOutput(true, “Link created successfully”, link.Id, link.Url,
link.Title, link.Description, link.ImageUrl, link.CreatedOn);
}

Now we are ready to run the application. Since we are not discussed the client applications, we can use the Banana Cake Pop client app to test the subscription. Here is the Subscription schema details.

You can write following GraphQL subscription code in the operations tab.

subscription {
onCreateLink {
id
title
description
}
}

And then click on the Run button. It will wait for the event, button will change to cancel – showing a progress circle, like this.

You can test it using a new browser window – one for subscription – right side – Chrome and another for mutation – left side Edge. Execute the Subscription code by clicking on the Run button and then execute the mutation code. This will create a link and which will send the event using ITopicEventSender instance SendAsync method. Here is the screen capture.

The subscription type in GraphQL is used to add real-time capabilities to our applications. Clients can subscribe to events and receive the event data in real-time, as soon as the server publishes it.

You can find more details about Subscriptions in HotChocolate here

You can find the source code in GitHub

Happy Programming 🙂