handzlikchris/FastScriptReload

Partial class merging doesn't keep namespace

RunninglVlan opened this issue · 0 comments

Here's my test:
Partial classes:

// TestClass1.1.cs
using TeamHalfBeard.Core;
using UnityEngine.InputSystem;

namespace TestNamespace {
    [Service(typeof(TestClass1))]
    public partial class TestClass1 : IUpdatable {
        public void Update(float deltaTime) {
            if (Keyboard.current.kKey.wasPressedThisFrame) {
                LogMessage("kek");
            }
        }
    }
}

// TestClass1.2.cs
using UnityEngine;

namespace TestNamespace {
    public partial class TestClass1 {
        private void LogMessage(string message) {
            Debug.Log($"{GetType().Name}.{message}");
        }
    }
}

Partial classes (result):

using TeamHalfBeard.Core;
using UnityEngine.InputSystem;
using UnityEngine;
[assembly:System.Runtime.CompilerServices.InternalsVisibleTo("Assembly-CSharp")]    [Service(typeof(TestClass1))]
    public partial  class TestClass1__Patched_:IUpdatable {
        public void Update(float deltaTime) {
            if (Keyboard.current.kKey.wasPressedThisFrame) {
                LogMessage("lol");
            }
        }
        private void LogMessage(string message) {
            Debug.Log($"{GetType().Name}.{message}");
        }

private static global::System.Collections.Generic.Dictionary<string, global::System.Func<object>> __Patched_NewFieldNameToInitialValueFn = new global::System.Collections.Generic.Dictionary<string, global::System.Func<object>>
{
};


private static global::System.Collections.Generic.Dictionary<string, global::System.Func<object>> __Patched_NewFieldsToGetTypeFnDictionaryFieldName = new global::System.Collections.Generic.Dictionary<string, global::System.Func<object>>
{
};

    }

Normal class:

// TestClass2.cs
using TeamHalfBeard.Core;
using UnityEngine;
using UnityEngine.InputSystem;

namespace TestNamespace {
    [Service(typeof(TestClass2))]
    public class TestClass2 : IUpdatable {
        public void Update(float deltaTime) {
            if (Keyboard.current.kKey.wasPressedThisFrame) {
                LogMessage("lol");
            }
        }

        private void LogMessage(string message) {
            Debug.Log($"{GetType().Name}.{message}");
        }
    }
}

Normal class (result):

using TeamHalfBeard.Core;
using UnityEngine;
using UnityEngine.InputSystem;

namespace TestNamespace {
    [Service(typeof(TestClass2))]
    public class TestClass2__Patched_: IUpdatable {
        public void Update(float deltaTime) {
            if (Keyboard.current.kKey.wasPressedThisFrame) {
                LogMessage("lol");
            }
        }

        private void LogMessage(string message) {
            Debug.Log($"{GetType().Name}.{message}");
        }

private static global::System.Collections.Generic.Dictionary<string, global::System.Func<object>> __Patched_NewFieldNameToInitialValueFn = new global::System.Collections.Generic.Dictionary<string, global::System.Func<object>>
{
};


private static global::System.Collections.Generic.Dictionary<string, global::System.Func<object>> __Patched_NewFieldsToGetTypeFnDictionaryFieldName = new global::System.Collections.Generic.Dictionary<string, global::System.Func<object>>
{
};

    }
}

Diff:

using TeamHalfBeard.Core;
using UnityEngine.InputSystem;
using UnityEngine;
+ namespace TestNamespace {
-[assembly:System.Runtime.CompilerServices.InternalsVisibleTo("Assembly-CSharp")]
    [Service(typeof(TestClass1))]
    public partial  class TestClass1__Patched_:IUpdatable {
        public void Update(float deltaTime) {
            if (Keyboard.current.kKey.wasPressedThisFrame) {
                LogMessage("lol");
            }
        }
        private void LogMessage(string message) {
            Debug.Log($"{GetType().Name}.{message}");
        }

private static global::System.Collections.Generic.Dictionary<string, global::System.Func<object>> __Patched_NewFieldNameToInitialValueFn = new global::System.Collections.Generic.Dictionary<string, global::System.Func<object>>
{
};


private static global::System.Collections.Generic.Dictionary<string, global::System.Func<object>> __Patched_NewFieldsToGetTypeFnDictionaryFieldName = new global::System.Collections.Generic.Dictionary<string, global::System.Func<object>>
{
};

    }
+}