Skip to content

Commit

Permalink
Add a test to verify that dotnet#71488 is fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekseyTs committed Jan 5, 2024
1 parent 9a316bb commit ac48dcb
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16932,7 +16932,7 @@ public void RefStructHandler_DynamicInHole(string expression)
[Theory]
[InlineData(@"$""Literal{1}""")]
[InlineData(@"$""Literal"" + $""{1}""")]
public void ConversionInParamsArguments(string expression)
public void ConversionInParamsArguments_01(string expression)
{
var code = @"
using System;
Expand Down Expand Up @@ -17006,6 +17006,31 @@ .locals init (CustomHandler V_0)
");
}

[Fact]
[WorkItem("https://github.com/dotnet/roslyn/issues/71488")]
public void ConversionInParamsArguments_02()
{
var code = @"
using System;
using System.Linq;
using System.Runtime.CompilerServices;

M("""", $""test"");

void M(string s, [InterpolatedStringHandlerArgument(nameof(s))] params CustomHandler[] handlers)
{
Console.WriteLine(string.Join(Environment.NewLine, handlers.Select(h => h.ToString())));
}
";

var comp = CreateCompilation(new[] { code, InterpolatedStringHandlerArgumentAttribute, GetInterpolatedStringCustomHandlerType("CustomHandler", "struct", useBoolReturns: false) });
comp.VerifyEmitDiagnostics(
// 0.cs(8,19): error CS8946: 'CustomHandler[]' is not an interpolated string handler type.
// void M(string s, [InterpolatedStringHandlerArgument(nameof(s))] params CustomHandler[] handlers)
Diagnostic(ErrorCode.ERR_TypeIsNotAnInterpolatedStringHandlerType, "InterpolatedStringHandlerArgument(nameof(s))").WithArguments("CustomHandler[]").WithLocation(8, 19)
);
}

[Theory]
[InlineData("static")]
[InlineData("")]
Expand Down

0 comments on commit ac48dcb

Please sign in to comment.