CosmosOS / Cosmos

Cosmos is an operating system "construction kit". Build your own OS using managed languages such as C#, VB.NET, and more!
https://www.goCosmos.org
BSD 3-Clause "New" or "Revised" License
2.93k stars 553 forks source link

Trying to set InputEncoding or OutputEncoding results in System.Exception error #2668

Closed KernelFox0 closed 1 year ago

KernelFox0 commented 1 year ago

Area of Cosmos - What area of Cosmos are we dealing with?

Cosmos ExtendedASCII failing to compile

Expected Behaviour - What do you think that should happen?

Adding the ExtendedASCII namespace and setting the encoding should allow us to display characters like █. It was working in a previous version.

Actual Behaviour - What unexpectedly happens?

Trying to make it work results in System.Exception without any details.

Reproduction - How did you get this error to appear?

Adding these lines of code to a project:

Encoding.RegisterProvider(CosmosEncodingProvider.Instance);
Console.InputEncoding = CosmosEncodingProvider.Instance.GetEncoding(437);
Console.OutputEncoding = CosmosEncodingProvider.Instance.GetEncoding(437);

Version - Were you using the User Kit or Dev Kit? And what User Kit version or Dev Kit commit (Cosmos, IL2CPU, X#)?

Latest possible devkit. (Commit 6802c4e)

This is the output log:

1>  Need plug for: System.Boolean  Interop+Kernel32.SetConsoleOutputCP(System.Int32)(Plug Signature: System_Boolean__Interop_Kernel32_SetConsoleOutputCP_System_Int32_ ).
1>  Static: True
1>  Assembly: System.Console, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
1>  Called from:
1>System.ConsolePal::Void SetConsoleOutputEncoding(System.Text.Encoding)
1>System.Console::Void set_OutputEncoding(System.Text.Encoding)

I reported this as a bug because it was working in a previous version.

zarlo commented 1 year ago

do you know what previous version it work in

KernelFox0 commented 1 year ago

Sadly I don't know the exact version. But I remember that the last time I updated before it broke with the newest was in November back in 2022

9xbt commented 1 year ago

Do it like this instead:

Console.InputEncoding = Cosmos.System.ExtendedASCII.CosmosEncodingProvider.Instance.GetEncoding(437);
Console.OutputEncoding = Cosmos.System.ExtendedASCII.CosmosEncodingProvider.Instance.GetEncoding(437);
KernelFox0 commented 1 year ago

The same problem happens.

KernelFox0 commented 1 year ago

I found a version where it still works: It's commit 189f4e1

https://github.com/CosmosOS/Cosmos/tree/189f4e1d9698db4062635a05b9a0eb820ff9a814

quajak commented 1 year ago

Is it broken with any newer commit?

gratejames commented 1 year ago

Just pulled the devkit last night, and I'm getting a different error. The code

Encoding ExtendedEncoding = Cosmos.System.ExtendedASCII.CosmosEncodingProvider.Instance.GetEncoding(437);
Console.OutputEncoding = ExtendedEncoding;

gives

bin/cosmos/Debug/net6.0/MyOS.asm:188956: error: undefined symbol `SystemVoidSystemStringarrayctorSystemInt32SystemInt32' (first use)
bin/cosmos/Debug/net6.0/MyOS.asm:188956: error:  (Each undefined symbol is reported only once.)

This, unfortunately, is wildly beyond my skill level. Do any of you with a better understanding have any ideas of how to resolve this?

pleasenoban commented 1 year ago

im working on a fix rn, InputEncoding and OutputEncoding only has a getter and not a setter because of a refactoring pr ( #2631 )