Unable to bind to http://localhost:5000 on the IPv6 loopback interface: ‘Cannot assign requested address’

To workaround the issue, add the code ENV ASPNETCORE_URLS=http://+:80 below the other ENV declarations at the top of the Dockerfile.develop file Dockerfile.develop after: FROM mcr.microsoft.com/dotnet/core/sdk:3.1 ARG BUILD_CONFIGURATION=Debug ENV ASPNETCORE_ENVIRONMENT=Development ENV DOTNET_USE_POLLING_FILE_WATCHER=true ENV ASPNETCORE_URLS=http://+:80 EXPOSE 80 Explanation Server URLs is one of the ASP.NET Core Web Host configuration values. It uses the environment variable ASPNETCORE_URLS and … Read more

How to enable Nullable Reference Types feature of C# 8.0 for the whole project

In Visual Studio 16.2 (from preview 1) the property name is changed to Nullable, which is simpler and aligns with the command line argument. Add the following properties to your .csproj file. <PropertyGroup> <Nullable>enable</Nullable> <LangVersion>8.0</LangVersion> </PropertyGroup> If you’re targeting netcoreapp3.0 or later, you don’t need to specify a LangVersion to enable nullable reference types. For … Read more

Can a C# class call an interface’s default interface method from its own implementation?

As far as I know you can’t invoke default interface method implementation in inheriting class (though there were proposals). But you can call it from inheriting interface: public class HappyGreeter : IGreeter { private interface IWorkAround : IGreeter { public void SayHello(string name) { (this as IGreeter).SayHello(name); System.Console.WriteLine(“I hope you’re doing great!!”); } } private … Read more

Default Interface Methods. What is deep meaningful difference now, between abstract class and interface? [closed]

There is not a lot of difference between the two apart from the obvious fact that abstract classes can have state and interfaces cannot. Default methods or also known as virtual extension methods have actually been available in Java for a while. The main drive for default methods is interface evolution which means being able … Read more

Nullable reference types with generic return type

You were very close. Just write your method like this: [return: MaybeNull] public T Get<T>(string key) { var wrapper = cacheService.Get(key); return wrapper.HasValue ? Deserialize<T>(wrapper) : default!; } You have to use the default! to get rid of the warning. But you can tell the compiler with [return: MaybeNull] that it should check for null … Read more

Nullable reference types: How to specify “T?” type without constraining to class or struct

What to do if you are using C# 9 In C# 9, you can use T? on an unconstrained type parameter to indicate that the type is always nullable when T is a reference type. In fact, the example in the original question “just works” after adding ? to the property and constructor parameter. See … Read more

Why does Visual Studio Type a Newly Minted Array as Nullable?

I would like to extend an existing answer by adding some links C# specification proposal says: nullable implicitly typed local variables var infers an annotated type for reference types. For instance, in var s = “”; the var is inferred as string?. It means that var for reference types infers a nullable reference type. This … Read more