@@ -4273,5 +4273,132 @@ void M(object obj) { }
42734273 // M<int>(default!);
42744274 Diagnostic ( ErrorCode . ERR_BadArity , "M<int>" ) . WithArguments ( "Program.M<T1, T2>(T1)" , "method" , "2" ) . WithLocation ( 5 , 9 ) ) ;
42754275 }
4276+
4277+ [ Fact ]
4278+ [ WorkItem ( "https://github.com/dotnet/roslyn/issues/80987" ) ]
4279+ public void MissingCoreReference_01 ( )
4280+ {
4281+ var source =
4282+ @"
4283+ namespace Magic
4284+ {
4285+ public enum Cookie : UInt32;
4286+ }
4287+ " ;
4288+ var comp = CreateEmptyCompilation ( source ) ;
4289+ comp . VerifyDiagnostics (
4290+ // (4,17): error CS0518: Predefined type 'System.Enum' is not defined or imported
4291+ // public enum Cookie : UInt32;
4292+ Diagnostic ( ErrorCode . ERR_PredefinedTypeNotFound , "Cookie" ) . WithArguments ( "System.Enum" ) . WithLocation ( 4 , 17 ) ,
4293+ // (4,26): error CS0518: Predefined type 'System.Enum' is not defined or imported
4294+ // public enum Cookie : UInt32;
4295+ Diagnostic ( ErrorCode . ERR_PredefinedTypeNotFound , "UInt32" ) . WithArguments ( "System.Enum" ) . WithLocation ( 4 , 26 ) ,
4296+ // (4,26): error CS0518: Predefined type 'System.Object' is not defined or imported
4297+ // public enum Cookie : UInt32;
4298+ Diagnostic ( ErrorCode . ERR_PredefinedTypeNotFound , "UInt32" ) . WithArguments ( "System.Object" ) . WithLocation ( 4 , 26 ) ,
4299+ // (4,26): error CS0246: The type or namespace name 'UInt32' could not be found (are you missing a using directive or an assembly reference?)
4300+ // public enum Cookie : UInt32;
4301+ Diagnostic ( ErrorCode . ERR_SingleTypeNameNotFound , "UInt32" ) . WithArguments ( "UInt32" ) . WithLocation ( 4 , 26 ) ,
4302+ // (4,26): error CS1008: Type byte, sbyte, short, ushort, int, uint, long, or ulong expected
4303+ // public enum Cookie : UInt32;
4304+ Diagnostic ( ErrorCode . ERR_IntegralTypeExpected , "UInt32" ) . WithLocation ( 4 , 26 )
4305+ ) ;
4306+ }
4307+
4308+ [ Fact ]
4309+ [ WorkItem ( "https://github.com/dotnet/roslyn/issues/80987" ) ]
4310+ public void MissingCoreReference_02 ( )
4311+ {
4312+ var source =
4313+ @"
4314+ namespace Magic
4315+ {
4316+ public enum Cookie : int;
4317+ }
4318+ " ;
4319+ var comp = CreateEmptyCompilation ( source ) ;
4320+ comp . VerifyDiagnostics (
4321+ // (4,17): error CS0518: Predefined type 'System.Enum' is not defined or imported
4322+ // public enum Cookie : int;
4323+ Diagnostic ( ErrorCode . ERR_PredefinedTypeNotFound , "Cookie" ) . WithArguments ( "System.Enum" ) . WithLocation ( 4 , 17 ) ,
4324+ // (4,26): error CS0518: Predefined type 'System.Int32' is not defined or imported
4325+ // public enum Cookie : int;
4326+ Diagnostic ( ErrorCode . ERR_PredefinedTypeNotFound , "int" ) . WithArguments ( "System.Int32" ) . WithLocation ( 4 , 26 )
4327+ ) ;
4328+ }
4329+
4330+ [ Fact ]
4331+ [ WorkItem ( "https://github.com/dotnet/roslyn/issues/80987" ) ]
4332+ public void MissingCoreReference_03 ( )
4333+ {
4334+ var source =
4335+ @"
4336+ namespace Magic
4337+ {
4338+ public class Cookie : UInt32;
4339+ }
4340+ " ;
4341+ var comp = CreateEmptyCompilation ( source ) ;
4342+ comp . VerifyDiagnostics (
4343+ // (4,27): error CS0246: The type or namespace name 'UInt32' could not be found (are you missing a using directive or an assembly reference?)
4344+ // public class Cookie : UInt32;
4345+ Diagnostic ( ErrorCode . ERR_SingleTypeNameNotFound , "UInt32" ) . WithArguments ( "UInt32" ) . WithLocation ( 4 , 27 )
4346+ ) ;
4347+ }
4348+
4349+ [ Fact ]
4350+ [ WorkItem ( "https://github.com/dotnet/roslyn/issues/80987" ) ]
4351+ public void MissingCoreReference_04 ( )
4352+ {
4353+ var source =
4354+ @"
4355+ namespace Magic
4356+ {
4357+ public struct Cookie : UInt32;
4358+ }
4359+ " ;
4360+ var comp = CreateEmptyCompilation ( source ) ;
4361+ comp . VerifyDiagnostics (
4362+ // (4,19): error CS0518: Predefined type 'System.ValueType' is not defined or imported
4363+ // public struct Cookie : UInt32;
4364+ Diagnostic ( ErrorCode . ERR_PredefinedTypeNotFound , "Cookie" ) . WithArguments ( "System.ValueType" ) . WithLocation ( 4 , 19 ) ,
4365+ // (4,28): error CS0246: The type or namespace name 'UInt32' could not be found (are you missing a using directive or an assembly reference?)
4366+ // public struct Cookie : UInt32;
4367+ Diagnostic ( ErrorCode . ERR_SingleTypeNameNotFound , "UInt32" ) . WithArguments ( "UInt32" ) . WithLocation ( 4 , 28 )
4368+ ) ;
4369+ }
4370+
4371+ [ Fact ]
4372+ [ WorkItem ( "https://github.com/dotnet/roslyn/issues/80987" ) ]
4373+ public void MissingCoreReference_05 ( )
4374+ {
4375+ var source =
4376+ @"
4377+ static class Ext
4378+ {
4379+ extension(Ext)
4380+ {
4381+ }
4382+ }
4383+ " ;
4384+ var comp = CreateEmptyCompilation ( source ) ;
4385+ comp . VerifyDiagnostics (
4386+ // (2,14): error CS0518: Predefined type 'System.Object' is not defined or imported
4387+ // static class Ext
4388+ Diagnostic ( ErrorCode . ERR_PredefinedTypeNotFound , "Ext" ) . WithArguments ( "System.Object" ) . WithLocation ( 2 , 14 ) ,
4389+ // (4,5): error CS0518: Predefined type 'System.Object' is not defined or imported
4390+ // extension(Ext)
4391+ Diagnostic ( ErrorCode . ERR_PredefinedTypeNotFound , "extension" ) . WithArguments ( "System.Object" ) . WithLocation ( 4 , 5 ) ,
4392+ // (4,5): error CS1110: Cannot define a new extension because the compiler required type 'System.Runtime.CompilerServices.ExtensionAttribute' cannot be found. Are you missing a reference to System.Core.dll?
4393+ // extension(Ext)
4394+ Diagnostic ( ErrorCode . ERR_ExtensionAttrNotFound , "extension" ) . WithArguments ( "System.Runtime.CompilerServices.ExtensionAttribute" ) . WithLocation ( 4 , 5 ) ,
4395+ // (4,14): error CS0518: Predefined type 'System.Void' is not defined or imported
4396+ // extension(Ext)
4397+ Diagnostic ( ErrorCode . ERR_PredefinedTypeNotFound , "(" ) . WithArguments ( "System.Void" ) . WithLocation ( 4 , 14 ) ,
4398+ // (4,15): error CS0518: Predefined type 'System.Object' is not defined or imported
4399+ // extension(Ext)
4400+ Diagnostic ( ErrorCode . ERR_PredefinedTypeNotFound , "Ext" ) . WithArguments ( "System.Object" ) . WithLocation ( 4 , 15 )
4401+ ) ;
4402+ }
42764403 }
42774404}
0 commit comments