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

NullReferenceException on Cosmos Build, when Scanning OpCodes if using ThunderboltIoc nugget package. #2857

Open Guillermo-Santos opened 11 months ago

Guillermo-Santos commented 11 months ago

This is the first of three problems found building Cosmos with different nugget packages.

This one throws a Null Reference exception when scanning the opcodes. Exception Post the exception returned by Visual Studio

Build started at 10:53 PM...
1>------ Build started: Project: CosmosKernel1, Configuration: Debug Any CPU ------
1>Skipping analyzers to speed up the build. You can execute 'Build' or 'Rebuild' command to run analyzers.
1>CosmosKernel1 -> D:\source\repos\Zaphyros\CosmosKernel1\bin\Debug\net6.0\CosmosKernel1.dll
1>Executing IL2CPU on assembly
1>Kernel Base: Cosmos.System.Kernel
1>Checking target assembly: D:\source\repos\Zaphyros\CosmosKernel1\bin\Debug\net6.0\CosmosKernel1.dll
1>IL2CPU : warning : Loading plugs from assembly: Cosmos.Core_Asm, Version=10.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983
1>IL2CPU : warning : Loading plugs from assembly: Cosmos.Core_Plugs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983
1>IL2CPU : warning : Loading plugs from assembly: Cosmos.Debug.Kernel.Plugs.Asm, Version=10.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983
1>IL2CPU : warning : Loading plugs from assembly: Cosmos.System2_Plugs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983
1>IL2CPU : error : Exception: System.NullReferenceException: Object reference not set to an instance of an object.
1>   at Cosmos.IL2CPU.ILOpCodes.OpVar.DoInitStackAnalysis(MethodBase aMethod) in D:\source\CosmosOS-Dev\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\ILOpCodes\OpVar.cs:line 99
1>   at Cosmos.IL2CPU.ILOpCode.InitStackAnalysis(MethodBase aMethod) in D:\source\CosmosOS-Dev\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\ILOpCode.cs:line 290
1>   at Cosmos.IL2CPU.ILReader.ProcessMethod(MethodBase aMethod) in D:\source\CosmosOS-Dev\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\ILReader.cs:line 660
1>   at Cosmos.IL2CPU.ILScanner.ScanMethod(MethodBase aMethod, Boolean aIsPlug, String sourceItem) in D:\source\CosmosOS-Dev\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 584
1>   at Cosmos.IL2CPU.ILScanner.ScanQueue() in D:\source\CosmosOS-Dev\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 751
1>   at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod, IEnumerable`1 plugsAssemblies) in D:\source\CosmosOS-Dev\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 270
1>   at Cosmos.IL2CPU.CompilerEngine.Execute() in D:\source\CosmosOS-Dev\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\CompilerEngine.cs:line 186
1>IL2CPU task took 00:00:00.3829526
1>Done building project "CosmosKernel1.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 10:53 PM and took 00.750 seconds ==========

Visual Studio Output Logs Post the entire output log given by Visual Studio for the build

How To Reproduce Add the ThunderboltIoc nugget package.

<PackageReference Include="ThunderboltIoc" Version="1.2.3" />

Write a simple service implementation and the register.

    public partial class FooThunderboltRegistration : ThunderboltRegistration
    {
        protected override void Register(IThunderboltRegistrar reg)
        {
            reg.AddScoped<IBarService, BarService>();
        }
    }

    public interface IBarService
    {

    }

    public class BarService : IBarService
    {

    }

Attach the register to the ThunderboltActivator class

ThunderboltActivator.Attach<FooThunderboltRegistration>();

Build the project. Screenshots

image

Context Before posting please confirm that the following are in order

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

zarlo commented 11 months ago

are you using a userkit or dev kit

Guillermo-Santos commented 11 months ago

are you using a userkit or dev kit

dev kit, forgot to say