abpframework / abp

Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
https://abp.io
GNU Lesser General Public License v3.0
13k stars 3.46k forks source link

Latest LangVersion is used by default in microservice template #19412

Open maskalek opened 8 months ago

maskalek commented 8 months ago

Is there an existing issue for this?

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?

maliming commented 8 months ago

hi

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

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

maskalek commented 8 months ago

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

maliming commented 8 months ago

I don't know the reason.