I have problems to implement any platform dependent classes in a MAUI project. The compiler produces errors if I use a method which has a return value.
I implemented the function first for each platform (eg. Windows):
namespace MauiApp.Platforms{ public partial class Memory { private string name = ""; partial void init() { name = "Windows"; } public partial string getName() { return name; } }}
Then I implement it in the core as follows:
namespace MauiApp.Platforms{ public partial class Memory { partial void init(); partial string getName(); }}
With the method 'init' there is no problem. It works and can be compiled.
But with the 'getName' I get the error that the partial method getName must have an accessibility modifier because it has a non-void return type as well as a missing member declaration error on each platform.But if I set the public modifier in the core method to fix this, the errors on each platform disappear, but I get the error, that I must have an implementation part because it has accessibility modifiers.So If I do any implementation in the core like:
public partial string getName() { return ""; }
I get more errors, that a partial method may not have multiple implementing declarations and no defining declaration found for implementing declaration on each platform.
Generally there seems to be a problem using access modifiers when implementing platform dependent methods. Access modifiers work on each platform but there is a problem in the shared method on the core. If no access modifier is used, compiler errors appear on each platform and if an access modifier is used, the complier requests any implementation, but this does not work too.
How can I implement platform dependent methods using return values and an access modifier as well in MAUI ?