UNITY_EDITOR in package

Hi,
we use UNITY_EDITOR to exclude debug code from production build and we use packages to easily share modules and stuff - after moving some functionality to a package, we found the problem that the UNITY_EDITOR branch is always inactive.

i know that this is not the best solution ( using editor code in non editor classes ) but it should be valid as far as i know

Not sure if it would work with packages, but in general you can add your own defines:

All the way at the bottom on there.

I haven’t done this myself so I can’t give specific guidance, but I’m guessing that you can do this by setting up the defines in your ASMDEF file for your package?

It does seem like a Unity bug, though, that this doesn’t work out of the box.

Are you sure about this?
Because I got curious and the first file I opened (Timeline package/Runtime/AnimationPreviewUtilities.cs) basically entirely in UNITY_EDITOR mode.

#if UNITY_EDITOR
using System.Collections.Generic;
using UnityEditor;


namespace UnityEngine.Timeline
{
    static class AnimationPreviewUtilities [...]

(the #endif is at the end of the file)

thanks for your suggestions - didnt find a way to achieve this with asmdef
@
have checked that file but couldnt debug it, looks exactly the same like the unity_editor parts in my package.
im not sure if its a debug problem, maybe some weird configs that have side effects - will check if its something debugger related, but all public properties of the monobehaviour we have surrounded by unity_editor are not visible in the editor and are not accessible by the class them self so it might be something compiling related

For now implemented a workaround - watcher class with callback events to store data outside of runtime package.
The smart solution would be a IoC framework to use injection and inception but thats different style of development ( and not easy possible in unity )

Currently we use Unity 2020.1.0b11 but found the problem while working with Unity 2019.2.11f1