Repository navigation
Remove unused parameter (IDE0060) on parameter used by [InterpolatedStringHandlerArgument] #62077
Copy link
Copy link
Open
Labels
Area-IDEBugFeature - IDE0060Remove unused parameterRemove unused parameterIDE-CodeStyleBuilt-in analyzers, fixes, and refactoringsBuilt-in analyzers, fixes, and refactoringshelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on itThe issue is "up for grabs" - add a comment if you are interested in working on it
Milestone
Description
Version Used:
Visual Studio 2022 Community 17.2.4
Microsoft (R) Visual C# Compiler version 4.2.0-4.22281.5 (8d3180e)
Steps to Reproduce:
Minimal code example
using System;
using System.Runtime.CompilerServices;
using System.Text;
public class Program
{
public void Test(IFormatProvider provider)
{
AppendLine(provider, $"test");
}
// unexpected IDE0060 on 'provider'
public void AppendLine(IFormatProvider provider, [InterpolatedStringHandlerArgument("provider")] ref DebugMarkerInterpolatedStringHandler name)
{
Console.WriteLine(name.GetString());
}
}
[InterpolatedStringHandler]
public unsafe ref struct DebugMarkerInterpolatedStringHandler
{
private StringBuilder.AppendInterpolatedStringHandler _innerHandler;
private StringBuilder _stringBuilder;
public DebugMarkerInterpolatedStringHandler(
int literalLength,
int formattedCount,
IFormatProvider provider)
{
_stringBuilder = new StringBuilder();
_innerHandler = new StringBuilder.AppendInterpolatedStringHandler(literalLength, formattedCount, _stringBuilder, provider);
}
public string GetString()
{
return _stringBuilder.ToString();
}
public void AppendLiteral(string value) => _innerHandler.AppendLiteral(value);
public void AppendFormatted<T>(T value) => _innerHandler.AppendFormatted(value);
public void AppendFormatted<T>(T value, string format) => _innerHandler.AppendFormatted(value, format);
public void AppendFormatted<T>(T value, int alignment) => _innerHandler.AppendFormatted(value, alignment);
public void AppendFormatted<T>(T value, int alignment, string format) => _innerHandler.AppendFormatted(value, alignment, format);
public void AppendFormatted(ReadOnlySpan<char> value) => _innerHandler.AppendFormatted(value);
public void AppendFormatted(ReadOnlySpan<char> value, int alignment = 0, string format = null) => _innerHandler.AppendFormatted(value, alignment, format);
public void AppendFormatted(string value) => _innerHandler.AppendFormatted(value);
public void AppendFormatted(string value, int alignment = 0, string format = null) => _innerHandler.AppendFormatted(value, alignment, format);
public void AppendFormatted(object value, int alignment = 0, string format = null) => _innerHandler.AppendFormatted(value, alignment, format);
}Expected Behavior:
No complaint from compiler.
Actual Behavior:
IDE0060 appears even though the format provider is used.
cc @333fred
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-IDEBugFeature - IDE0060Remove unused parameterRemove unused parameterIDE-CodeStyleBuilt-in analyzers, fixes, and refactoringsBuilt-in analyzers, fixes, and refactoringshelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on itThe issue is "up for grabs" - add a comment if you are interested in working on it
Type
Projects
- StatusShow more project fieldsInQueue
Activity
DoctorKrolic commentedon Jun 22, 2022
Duplicate of #58168
TechPizzaDev commentedon Jun 22, 2022
Issue #58168 is invalid. The arguments in the given screenshot are unused and there is no interaction with
[InterpolatedStringHandlerArgument]there either.