revolt
Partial classes and platform specific code
You are right I should use one of attributes provided, but I believe that is a seperate issue to my original problem. In regards to the bad msbuild, are you saying that it takes the host OS when building and not the target os? So instead of using IsOSPlatform I would use something like Condition="$(RuntimeIdentifier.StartsWith('win'))" instead, like a commenter above pointed out. However this just brings me back to the error of "Partial method 'Platform.SetWallpaper(string)' must have an implementation part because it has accessibility modifiers." correct? My goal was to use partial classes and conditional compilation similair to maui example. I do appreciate everyones help though 🙂
55 replies
Partial classes and platform specific code
Thanks for the example code. I ended up doing it at runtime pretty much how you showed here. My only question is that do u think originally that publishing it using the args you provided would have worked? I'd go back and try but didnt use git
55 replies
Partial classes and platform specific code
Just looking at this article
it seems like its okay to define it with access modifier? Sorry still learning
https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/invoke-platform-code?view=net-maui-8.0
55 replies
Partial classes and platform specific code
Hmm. So would that mean that the condition is not met in csproj, therefore the compiler removes the code (implementations) specified using #if? (Expected if csproj is wrong) Or is it now correct and that my actual code is wrong.
55 replies
❔ Properly calling "await login()" in web service constructor
Thanks for the reply. not sure exactly what you mean. If the Connect method wasnt asynchronous I would just throw it in the constructor directly, and then as a singleton Connect would just be called once on program start automatically, correct? I'm pretty much just asking how to replicate that behaviour. Since it is asynchronous and contructor cant call asynchronous methods directly, this is the workaround to do it. The only problem now is that I have to call InitializeAsync somewhere. So if im in the web controller, instead of just accessing SSService with DI and _client would be connected already, I have to make sure that it is connected by calling EnsureInitializedAsync. - If connected, do nothing, if not InitializeAsync will be called automatically. If there is another place where I can just call InitializeAsync once on program start, that would be ideal instead of calling EnsureInitializedAsync everytime SSService is used. Hopefully I am clear enough, because again i'm kind of a beginner so just trying to wrap my head around this. Thanks!
16 replies