Loading ...

How to get C# of version 9 in Acumatica class library

Hello everybody,

today I want to share with you following error message:

Feature 'lambda discard parameters' is not available in C# 7.3. Please use language version 9.0 or greater.

 

I had a code below:

 

public void RegisterParallelProcesses(int count)
{
    ParallelProcessingOptions = options =>
    {
        options.AutoBatchSize = false;
        options.BatchSize = 1;
        options.IsEnabled = true;
        options.SplitToBatches = (__) => SplitProcess(count);
    };
}

Another error message I've faced was: Feature 'target-typed object creation' is not available in C# 7.3. Please use language version 9.0 or greater.

It was related to the code below:

 

public static void ProcessOrder(SOOrderEntry graphSOOrderBlueprint order)
        {
            graph.Clear();
            // Insert the order and set required fields
            SOOrder newOrder = graph.Document.Insert(new()
            {
                OrderType = order.OrderType,
            });
 
            newOrder.CustomerID = order.CustomerID;
            graph.Document.UpdateCurrent();

 

 

In order to deal with both of these problems, I used following modification of csproj file:

  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{080F3E72-6B37-422C-A8E5-589DE642DCB6}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>AcuPower.VirtualDevCon2024</RootNamespace>
    <AssemblyName>AcuPower.VirtualDevCon2024</AssemblyName>
    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <Deterministic>true</Deterministic>
	<LangVersion>9.0</LangVersion>
  </PropertyGroup>

 

So, if you want to get new features of C# 9.0, then make sure to make this modification in property group.