Skip to content

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

Open
@Guillermo-Santos

Description

@Guillermo-Santos

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

  • Both Cosmos VS Extensions are installed
  • In the NuGet Package Manager "Include prerelease" is selected
  • The Cosmos NuGet package store is selected (NOT nuget.org) in 'Manage NuGet Packages'
  • The Cosmos NuGet packages are installed

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions