revolt
revolt
CC#
Created by revolt on 9/30/2024 in #help
Partial classes and platform specific code
And yes just for something simple I think we have established that conditional calling based on platform is probably the best bet, but I would still like to see why this wasn't working for me.
55 replies
CC#
Created by revolt on 9/30/2024 in #help
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
CC#
Created by revolt on 9/30/2024 in #help
Partial classes and platform specific code
so i took a quick look and this only seems to apply to ide/dev ux and warnings and does not affect compilation
55 replies
CC#
Created by revolt on 9/30/2024 in #help
Partial classes and platform specific code
will take a look, thanks
55 replies
CC#
Created by revolt on 9/30/2024 in #help
Partial classes and platform specific code
I was mainly talking about in my specific example with partial classes, thank you for the test though 🙂
55 replies
CC#
Created by revolt on 9/30/2024 in #help
Partial classes and platform specific code
If you can provide an example that would be great, just looking at it seems too complicated for this use case
55 replies
CC#
Created by revolt on 9/30/2024 in #help
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
CC#
Created by revolt on 9/30/2024 in #help
Partial classes and platform specific code
ur good. I think it points back to the csproj being wrong again, but im not sure.
55 replies
CC#
Created by revolt on 9/30/2024 in #help
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
CC#
Created by revolt on 9/30/2024 in #help
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
CC#
Created by revolt on 9/30/2024 in #help
Partial classes and platform specific code
sorry to expand on it I now get the below error: Partial method 'Platform.SetWallpaper(string)' must have an implementation part because it has accessibility modifiers.
55 replies
CC#
Created by revolt on 9/30/2024 in #help
Partial classes and platform specific code
Thanks for the help. Just checked out that github and tried the below and it now works on windows but not linux. Gonna look at some more stuff now that you linked
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('linux'))">
<DefineConstants>$(DefineConstants);LINUX</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('win'))">
<DefineConstants>$(DefineConstants);WINDOWS</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('linux'))">
<DefineConstants>$(DefineConstants);LINUX</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('win'))">
<DefineConstants>$(DefineConstants);WINDOWS</DefineConstants>
</PropertyGroup>
55 replies
CC#
Created by revolt on 9/30/2024 in #help
Partial classes and platform specific code
Thought partials would be a good use case for this, but cmiiw and if a easier way exists
55 replies
CC#
Created by revolt on 12/21/2023 in #help
CancelKeyPress not being handled/interrupted correctly
Adding more to main cause of message limit. My goal is to simply interrupt the default behaviour of ctrl+c and stop the spawned child manually without stopping the main process
2 replies
CC#
Created by revolt on 1/30/2023 in #help
❔ 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