dotnet/roslyn

Quite confusing error message CS0282

オープン

#32,305 opened on 2019/01/09

 (2 件のコメント) (0 件のリアクション) (0 人の担当者)C# (4,257 件のフォーク)batch import
Area-CompilersBugConcept-Diagnostic Clarityhelp wanted

Repository metrics

Stars
 (20,414 個のスター)
PR merge metrics
 (平均マージ 6d 17h) (30d で 256 merged PRs)

説明

Version Used: Microsoft (R) Visual C# Compiler version 2.8.2.62916 (2ad4aabc)

Steps to Reproduce:

  1. Compile following code
using System;
using System.Runtime.InteropServices;

partial class Exception2
{
	protected event Action a;
}

[StructLayout (LayoutKind.Sequential)]
partial class Exception2
{
	protected event Action b;
}

Expected Behavior:

A warning which makes sense

Actual Behavior:

warning CS0282: There is no defined ordering between fields in multiple declarations of partial struct 'Exception2'. To specify an ordering, all instance fields must be in the same declaration.

  • there is no struct 'Exception2' (it's a class)
  • referring to events underlying implementation fields is also confusing

コントリビューターガイド