abp icon indicating copy to clipboard operation
abp copied to clipboard

Latest LangVersion is used by default in microservice template

Open maskalek opened this issue 11 months ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Description

I have a project built using microservice ABP template 7.3.* version. I am using docker that uses .NET SDK 7 to build images. I have both .NET SDK 7 and SDK 8 locally.

The problem is that when I am using ReSharper and it suggests me use primary constructor (that part of C# 12). Of course, it fails when I try to deploy since this feature is not available in .NET 7 compiler.

Trying to understand the problem, I found out that common.props in the root folder contains <LangVersion>latest</LangVersion>

By default, If this property is not explicitly set, the project defaults to the latest major version of C# supported by the .NET SDK targeted by your project. Latest means "The compiler accepts syntax from the latest released version of the compiler".

So, to not get confused and have similar problems in the future, we are thinking about removing this line (alternative would be to migrate to .NET 8), but apparently in our shared projects target framework is netstandard2.0 and they are not compiled since some syntax from .NET 7 have been used there :)

I would suggest removing this line from the template. I don't see a lot of sense in overriding default c# behaviour. It would be nice to hear other opinions on this matter/explanation of why it is like that/mistakes in my explanation. What do you think?

maskalek avatar Mar 25 '24 12:03 maskalek

hi

Have you tried adding globa.json to specify the net SDK?

https://learn.microsoft.com/en-us/dotnet/core/tools/global-json#sdk

maliming avatar Mar 26 '24 07:03 maliming

@maliming no, but I am pretty sure it will work. But the question is why we would need to add anything at all?

maskalek avatar Mar 26 '24 07:03 maskalek

I don't know the reason.

maliming avatar Mar 26 '24 07:03 maliming