Skip to content

ambiguous in line 'sb.Append($"Test1\n");' #283

@SMAH1

Description

@SMAH1

Code of csproj and Program.cs:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <OutputType>exe</OutputType>
    <TargetFramework>net9.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <InvariantGlobalization>true</InvariantGlobalization>
    <PublishAot>true</PublishAot>
    <IsAotCompatible>true</IsAotCompatible>
    <LangVersion>preview</LangVersion>
    <PlatformTarget>x64</PlatformTarget>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="LinkDotNet.StringBuilder" Version="3.4.1" />
  </ItemGroup>

</Project>
using LinkDotNet.StringBuilder;

using scoped ValueStringBuilder sb = new(100);
int age = 42;
sb.Append($"Test1\n");
sb.Append($"Test2 {age}\n");
sb.Append("Test3\n");
sb.Append("Test4\n".AsSpan());
Console.WriteLine(sb.ToString());

Compile AOT in Windows (dotnet publish -r win-x64 -c Release -o .\publish) : OK
Compile AOT in linux (dotnet publish -r linux-x64 -c Release -o ./publish) : Error

/..../Program.cs(5,4): error CS0121: The call is ambiguous between the following methods or properties: 'ValueStringBuilder.Append(scoped ReadOnlySpan<char>)' and 'ValueStringBuilder.Append(ref ValueStringBuilder.AppendInterpolatedStringHandler)'

in line:

sb.Append($"Test1\n");

Extran info:

.NET SDK:
 Version:           9.0.112
 Commit:            191254d648
 Workload version:  9.0.100-manifests.b3871ecb
 MSBuild version:   17.12.50+191254d64

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         ubuntu.22.04-x64
 Base Path:   /usr/lib/dotnet/sdk/9.0.112/

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.11
  Architecture: x64
  Commit:       191254d648

.NET SDKs installed:
  9.0.112 [/usr/lib/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 9.0.11 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 9.0.11 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions