Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial class merging doesn't keep namespace #137

Open
RunninglVlan opened this issue Sep 5, 2024 · 0 comments · May be fixed by #149
Open

Partial class merging doesn't keep namespace #137

RunninglVlan opened this issue Sep 5, 2024 · 0 comments · May be fixed by #149

Comments

@RunninglVlan
Copy link
Contributor

RunninglVlan commented Sep 5, 2024

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>>
{
};

    }
+}
RunninglVlan added a commit to RunninglVlan/FastScriptReload that referenced this issue Nov 14, 2024
@RunninglVlan RunninglVlan linked a pull request Nov 14, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant