How to productively create shell compatibility (shims), for .Net Core , Framework , Standard ?
Versions: Framework 4.6.1 ; Core 2.0 ; Standard 2.0 .
For example, the following 3 items are of interest, for use between the .net core , .net standard and the .net framework :
System.Windows.Threading.Dispatcher , System.ComponentModel.ItemPropertyInfo.Descriptor , even System.Windows.Controls.MenuItem .
In fact, it seems that such shells need a lot more. Of course, they can be created manually. But maybe there is a more productive way to avoid mechanical work?
Explanation of the problem in a rough example, if done manually:
For example, for Core 2.0 , the Dispatcher not implemented.
An abstract shell / interface / facade is made:
public enum DispatcherShimPriority { Background //... } public interface DispaicherShim { void Invoke(Action action, DispatcherShimPriority prio); void BeginInvoke(Action action, DispatcherShimPriority, prio); } Further 2 implementations:
public class DispatcherCore: DispaicherShim; //здесь по началу можно просто вызывать Action and
public class DispatcherFramework: DispaicherShim; //здесь используется реальный Dispatcher внутри Next is some kind of multinational activator class, for example, Shims , in which:
public static DispaicherShim CreateDispatcher() { #if NETCOREAPP2_0 return new DispatcherCore(); #else return new DispatcherFramework(); #endif } Thus, it turns out a shell that can be used both in Framework's and Core's applications.
The creation of such shells requires a lot of mechanical work. Intuitively, it seems to me that it is not necessary to do this work, that there are ready-made solutions ...
About Microsoft.Windows.Compatibility pack in the know. I mean the creation of shells for elements that are not covered by this package.
About Microsoft.Windows.Compatibility.Shims heard, but I suspect that there are no shells for elements that are not covered by the package itself.
The overall task is to transfer the main part of the WPF application to the core for the potential web-client (leaving WPF running), while many of the main framework's .net elements are not translated to the core.
Asp.Net Coreapplication there will be, for example, forwarding a bar progress change or other UI changes. But it is too early to talk about specifics. For now, just callingAction. And theDispatcheris just one of many examples .... - Andrey K.