Facepunch / sbox-issues

173 stars 11 forks source link

Custom Tool Addons: Project Reference to Custom Tool Removed During Gamemode Compilation #2228

Closed LeQuackers closed 1 month ago

LeQuackers commented 1 year ago

Describe the bug

I have a tools addon for my gamemode that has attributes that are used in said gamemode. After adding a reference to my tools addon in my gamemode addon, everything seems to work and VS2022 will build the solution without errors; however, when I launch s&box the gamemode compilation fails and upon inspection the reference to my tools addon is removed.

To Reproduce

  1. Copy the tool snippet and paste it into a minimal tool addon.
  2. Copy the gamemode snippet and paste it into a minimal gamemode addon.
  3. Add a reference to the tool addon in the gamemode so the MyToolAttribute can be used.
  4. Open s&box.
  5. Upon inspection, the reference to the tool addon will be removed.

Expected behavior

The reference is not removed and my gamemode can use the tools that are build for it.

Media/Files

The tool addon's attribute:

// From the tool addon.
using System;

namespace MyTools
{
    public class MyToolAttribute : Attribute
    {
        public string Property { get; set; }

        public MyToolAttribute( string property )
        {
            Property = property;
        }
    }
}

The tool addon's attribute being used in the gamemode:

// From the gamemode addon
using MyTools;
using Sandbox;

namespace MyGamemode
{
    [GameResource( "Test Definition", "test", "Describes a test resource." )]
    public class TestResource : GameResource
    {
        [MyTool( "Foo" )]
        public string Bar { get; set; }
    }
}

Additional context

No response

garrynewman commented 1 year ago

I'm not sure how you expect this to work, since you can't publish tool addons?

gio3k commented 1 year ago

I talk about this issue a little in my comment here

https://github.com/sboxgame/issues/issues/2616#issuecomment-1467597098