TypeScript is not type safe

Let’s say we have an API that return true or false ( TILT – Things I learned Today – http://tiltwebapp.azurewebsites.net/  – returns true if I have learned something today )

What is wrong with this code:

public HasTILTToday():Observable<boolean>{

if(!this.wasLoggedIn)return of(false);

return this.http.get<string>(this.baseUrl+’TILT/HasTILTToday’, {

headers: new HttpHeaders(


‘Authorization’: ‘CustomBearer ‘ + this.jwt,

‘Content-Type’: ‘application/json’


responseType: ‘text’ as ‘json’})




Answer : When you subscribe,even the variable is boolean, when you go with typeof is a string ( that contains “true” or “false” ). And this, when you use  a *ngIf =”the bool” – it will have undexpected behaviours.

Solution? The rxjs pipe

public HasTILTToday():Observable<boolean>{

if(!this.wasLoggedIn)return of(false);

return this.http.get<string>(this.baseUrl+’TILT/HasTILTToday’, {

headers: new HttpHeaders(


‘Authorization’: ‘CustomBearer ‘ + this.jwt,

‘Content-Type’: ‘application/json’


responseType: ‘text’ as ‘json’})





[ADCES]–WebAPI and Flutter

Tomorrow is another ADCES meetup  –

InteractingWithWebAPI & A day with Flutter shoes

Prezentare 1 : InteractingWithWebAPI , Andrei Ignat, http://msprogrammer.serviciipeweb.ro/

Descriere: Cum interactionam cu WebAPI astfel incit sa putem sa facem un demo pentru FrontEnd developer

Prezentare 2 : A day with Flutter shoes , Alex Bordei, https://whiz.ro/

Waiting for you at


Busy with TILT

Just thinking to a new application –  TILT – Things I Learned Today . It will allow me to verify Database 2 Code – an sample project – and many of Roslyn Source Code Generators. If you want to participate, just let me know.

It will be on Azure as most as possible – and with applications deployed to all major stores ( Microsoft,  Google, Apple)

I will post the progress here.

Passing from .NET 5 to .NET 6

First, read the document here: Migrate from ASP.NET Core 5.0 to 6.0 | Microsoft Docs .\

So those were my steps ( fully compile after each step ):

1. Replace in csproj net5.0 with net6.0


2.  Update all nugets reference to the latest version

3.  Add globals.cs with various usings

4. Add globals.cs . Mine looks this way ( without the necessary for the project)

global using Microsoft.AspNetCore.Hosting;
global using Microsoft.AspNetCore.Http;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.Hosting;
global using Microsoft.Extensions.Logging;
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Threading.Tasks;
global using Microsoft.AspNetCore.Mvc;
global using Microsoft.AspNetCore.Mvc.ApiExplorer;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Options;
global using Microsoft.OpenApi.Models;
global using Swashbuckle.AspNetCore.SwaggerGen;
global using Microsoft.AspNetCore.Builder;
global using AMSWebAPI;
global using appSettingsEditor;
global using HealthChecks.UI.Client;
global using Hellang.Middleware.ProblemDetails;
global using Microsoft.AspNetCore.Diagnostics.HealthChecks;
global using Microsoft.AspNetCore.HttpOverrides;
global using NetCore2BlocklyNew;

5.  Move away from Startup – put all in program .cs  – easy : services moved to app.Services , and instead of parameters in configure, use the app.Services – example

var provider = app.Services.GetRequiredService<IApiVersionDescriptionProvider>();

6.  Tests

I have a problem with  “ The server has not been started or no web application was configured. “  -when I configure WebApplicationFactory<Program> 

Reading Minimal APIs in .NET 6 but where are the Unit Tests? – Scott Hanselman’s Blog 

Testing in .NET 6 with WebApplicationFactory (including Minimal APIs) | by Lee Dale | Medium

Supporting integration tests with WebApplicationFactory in .NET 6: Exploring .NET 6 – Part 6 (andrewlock.net)

Integration tests in ASP.NET Core | Microsoft Docs

No avail yet.  Should study ore.

Templating Roslyn Source Code Generators

I want that , when I generate code with Roslyn, to have a template that I can easy modify to generate code . Also, I want to let the user ( the programmer , in this case) modify this template  – maybe he has better ideas than me.

For reading from the RSCG, is pretty simple: Make as an embedded resource and read with

internal class EmbedReader
     static Assembly assembly;
     static EmbedReader()
         assembly = Assembly.GetExecutingAssembly();

     public static string ContentFile(string name)
         var resourceName = name;

        using (Stream stream = assembly.GetManifestResourceStream(resourceName))
         using (StreamReader reader = new StreamReader(stream))
             string result = reader.ReadToEnd();
             //this is the content

For let the programmer user put his template, put as as additional file in the csproj

         <AdditionalFiles Include=”context.txt”  />


and read with

var file = context.AdditionalFiles.Where(it => it.Path.EndsWith($”{val}.txt”))
                     .Select(it => it.GetText())

            if (file != null)
                 content = string.Join(Environment.NewLine, file.Lines.Select(it => it.ToString()));

To do both,if the result of the first is empty, read the second (or opposite ? )

Andrei Ignat weekly software news(mostly .NET)

* indicates required

Please select all the ways you would like to hear from me:

You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.