Hello World doesn't work with reflection disabled in NAOT
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 144
Description
```
$ ./output/fs-hello-world
Unhandled Exception: EETypeRva:0x0037B3E0: TypeInitialization_Type_NoTypeAvailable
---> EETypeRva:0x0037B3E0: TypeInitialization_Type_NoTypeAvailable
---> EETypeRva:0x0037AA80: Reflection_Disabled
```
**Repro steps**
```
dotnet new console -n fs-hello-world -lang F# && cd fs-hello-world
dotnet publish \
-p:SelfContained=true \
-p:PublishAot=true \
-p:IlcDisableReflection=true \
-o ./output
./output/fs-hello-world
```
Program.fs:
```
printfn "Hello from F#"
```
**Expected behavior**
Prints hello world
**Actual behavior**
```
Unhandled Exception: EETypeRva:0x0037B3E0: TypeInitialization_Type_NoTypeAvailable
---> EETypeRva:0x0037B3E0: TypeInitialization_Type_NoTypeAvailable
---> EETypeRva:0x0037AA80: Reflection_Disabled
at Internal.Reflection.RuntimeTypeInfo.GetMethodImpl(String, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[]) + 0x5a
at System.Type.GetMethod(String, BindingFlags) + 0x5a
at .$Printf..cctor() + 0x4d
at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0x158
Exception_EndOfInnerExceptionStack
at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0x253
at System.Runtime.CompilerServices.ClassConstructorRunner.CheckStaticClassConstructionReturnNonGCStaticBase(StaticClassConstructionContext*, IntPtr) + 0x1b
at Microsoft.FSharp.Core.PrintfImpl..cctor() + 0x9
at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0x158
Exception_EndOfInnerExceptionStack
at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0x253
at System.Runtime.CompilerServices.ClassConstructorRunner.CheckStaticClassConstructionReturnNonGCStaticBase(StaticClassConstructionContext*, IntPtr) + 0x1b
at Microsoft.FSharp.Core.PrintfImpl.revToArray[T](Int32, FSharpList`1) + 0x36
at Microsoft.FSharp.Core.PrintfImpl.FormatParser`4.parseAndCreateFuncFactoryAux(FSharpList`1, String, Type, Int32&) + 0xbb
at Microsoft.FSharp.Core.PrintfImpl.FormatParser`4.parseAndCreateFunctionFactory() + 0xee
at Microsoft.FSharp.Core.PrintfImpl.FormatParser`4.GetCurriedPrinterFactory() + 0x38
at Microsoft.FSharp.Core.PrintfModule.gprintf[a, TState, TResidue, TResult, TPrinter](FSharpFunc`2, PrintfFormat`4) + 0xac
at .$Program.main@() + 0x44
at sandbox-1668861381!+0x228cc9
at sandbox-1668861381!+0x228d3c
Aborted
```
* debian 12
* gcc (Debian 12.2.0-9) 12.2.0
* Debian clang version 14.0.6
* SDK 7.0.100
Contributor guide
Assessment
This issue has not been assessed yet.