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.94k stars 552 forks source link

IL2CPU Error When File System Is Added. #2825

Closed bennytrt closed 1 year ago

bennytrt commented 1 year ago

Have you checked Github Issues for similar errors?

Exception Post the exception returned by Visual Studio

Severity Code Description Project File Line Suppression State Error Exception: System.Exception: AtOS C:\Users\super\OneDrive\Bureaublad\prjfiles\AtOS\AtOS\IL2CPU 1

Visual Studio Output Logs Post the entire output log given by Visual Studio for the build Build started at 9:03 PM... 1>------ Build started: Project: AtOS, Configuration: Debug Any CPU ------ 1>Skipping analyzers to speed up the build. You can execute 'Build' or 'Rebuild' command to run analyzers. 1>AtOS -> C:\Users\super\OneDrive\Bureaublad\prjfiles\AtOS\AtOS\bin\Debug\net6.0\AtOS.dll 1>Message: Executing IL2CPU on assembly 1>Message: Kernel Base: Cosmos.System.Kernel 1>Message: Checking target assembly: C:\Users\super\OneDrive\Bureaublad\prjfiles\AtOS\AtOS\bin\Debug\net6.0\AtOS.dll 1>Message : warning : Loading plugs from assembly: Cosmos.Core_Asm, Version=10.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983 1>Message : warning : Loading plugs from assembly: Cosmos.Core_Plugs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983 1>Message : warning : Loading plugs from assembly: Cosmos.Debug.Kernel.Plugs.Asm, Version=10.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983 1>Message : warning : Loading plugs from assembly: Cosmos.System2_Plugs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983 1>IL2CPU : error : Exception: System.Exception: 1>Native code encountered, plug required. 1> DO NOT REPORT THIS AS A BUG. 1> Please see http://www.gocosmos.org/docs/plugs/missing/ 1> Need plug for: System.String[] System.Environment.GetCommandLineArgsNative()(Plug Signature: System_String__System_Environment_GetCommandLineArgsNative ). 1> Static: True 1> Assembly: System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e 1> Called from: 1>System.Environment::System.String[] GetCommandLineArgs() 1>AtOS.Kernel::Void Run() 1>Cosmos.System.Kernel::Void Run() 1> 1> 1> at Cosmos.IL2CPU.ILScanner.ScanMethod(MethodBase aMethod, Boolean aIsPlug, String sourceItem) in C:\Development\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 625 1> at Cosmos.IL2CPU.ILScanner.ScanQueue() in C:\Development\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 816 1> at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod, IEnumerable`1 plugsAssemblies) in C:\Development\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 276 1> at Cosmos.IL2CPU.CompilerEngine.Execute() in C:\Development\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\CompilerEngine.cs:line 223 1>IL2CPU task took 00:00:00.5831767 1>Done building project "AtOS.csproj" -- FAILED. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== ========== Build completed at 9:03 PM and took 00.859 seconds ==========

How To Reproduce private void FileSys(string[] arguments) { fileSystemResponse = string.Empty;

        if (arguments.Length < 3)
        {
            fileSystemResponse = "Error: Insufficient arguments!";
            return;
        }

        string action = arguments[0];
        string itemType = arguments[1];
        string itemName = arguments[2];

        Console.WriteLine($"{action} {itemType} '{itemName}'?");
        Console.WriteLine("[Yes\\No]");

        string answer = Console.ReadLine();

        if (answer.Equals("Yes", StringComparison.OrdinalIgnoreCase))
        {
            try
            {
                switch (action)
                {
                    case "-c":
                        if (itemType.Equals("file", StringComparison.OrdinalIgnoreCase))
                        {
                            Cosmos.System.FileSystem.VFS.VFSManager.CreateFile(itemName);
                            fileSystemResponse = $"File '{itemName}' successfully created! [Empty file]";
                        }
                        else if (itemType.Equals("directory", StringComparison.OrdinalIgnoreCase))
                        {
                            Cosmos.System.FileSystem.VFS.VFSManager.CreateDirectory(itemName);
                            fileSystemResponse = $"Folder '{itemName}' successfully created";
                        }
                        else
                        {
                            fileSystemResponse = "Unexpected file type.";
                        }
                        break;

                    case "-r":
                        if (itemType.Equals("file", StringComparison.OrdinalIgnoreCase))
                        {
                            Cosmos.System.FileSystem.VFS.VFSManager.DeleteFile(itemName);
                            fileSystemResponse = $"File '{itemName}' successfully removed!";
                        }
                        else if (itemType.Equals("directory", StringComparison.OrdinalIgnoreCase))
                        {
                            Cosmos.System.FileSystem.VFS.VFSManager.DeleteDirectory(itemName, true);
                            fileSystemResponse = $"Folder '{itemName}' successfully removed";
                        }
                        else
                        {
                            fileSystemResponse = "Unexpected file type.";
                        }
                        break;

                    case "-w":
                        if (arguments.Length >= 4)
                        {
                            string text = string.Join(" ", arguments.Skip(3));
                            byte[] data = Encoding.ASCII.GetBytes(text);

                            using (var fs = (System.IO.FileStream)Cosmos.System.FileSystem.VFS.VFSManager.GetFile(itemName).GetFileStream())
                            {
                                fs.Write(data, 0, data.Length);
                            }

                            fileSystemResponse = "Successfully written to file!";
                        }
                        else
                        {
                            fileSystemResponse = "Error: Insufficient arguments for file writing.";
                        }
                        break;

                    default:
                        fileSystemResponse = $"Unexpected action '{action}'";
                        break;
                }
            }
            catch (Exception ex)
            {

                Console.WriteLine($"Exception during filesystem operation: {ex.GetType().Name}: {ex.Message}");

                fileSystemResponse = "An error occurred during filesystem operation.";
            }
        }
        else
        {
            fileSystemResponse = "User has canceled.";
        }
    }

Screenshots basically no screenshots would help as it occurs at the start of building/debugging.

Context Before posting please confirm that the following are in order [ ] Both Cosmos VS Extensions are installed : Yes [ ] In the NuGet Package Manager "Include prerelease" is selected : Yes [ ] The Cosmos NuGet package store is selected (NOT nuget.org) in 'Manage NuGet Packages' : Yes [ ] The Cosmos NuGet packages are installed : Yes

Add any other context about the problem which might be helpful.

zarlo commented 1 year ago

GetCommandLineArgs() is not supported

bennytrt commented 1 year ago

okay thank you