dotnet/roslyn
Invalid IDE0059 When using constant inside static local function
开放
#44,948 创建于 2020年6月8日
Area-IDEBugFeature - IDE0059help wanted
仓库指标
- 星标
- (20,414 个星标)
- PR 合并指标
- (平均合并 6天 17小时) (30 天内合并 256 个 PR)
描述
Version Used: Visual Studio 16.6.1
Steps to Reproduce:
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
var local = FormatDate(DateTime.Now);
var utc = FormatUtcDate(DateTime.Now);
Console.WriteLine("{0} -> {1}", local, utc);
Console.ReadKey();
const string DatePickerFormat = "MM/dd/yyyy hh:mm";
static string FormatDate(DateTime? date) => date?.ToString(DatePickerFormat);
static string FormatUtcDate(DateTime? date) => date?.ToUniversalTime().ToString(DatePickerFormat);
}
}
}
Expected Behavior: No IDE0059 notice will be shown for DatePickerFormat because it is used by the static local functions FormatDate and FormatUtcDate.
Actual Behavior: An IDE0059 notice is shown for DatePickerFormat .