Replies: 7 comments 1 reply
-
IMO "net7.0" isn't a "fallback", it's a standard platform. The code where you're adding services could be run on "net7.0", which includes apps like console apps. You could wrap that call in a platform directive so it wouldn't be run on net7.0 and only on the platforms and you wouldn't need to write the implementation. IMO this feels more like a misunderstanding of how to lay out code rather than something that would need yet another abstraction within MAUI to handle. |
Beta Was this translation helpful? Give feedback.
-
Hi @nk54. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
Beta Was this translation helpful? Give feedback.
-
Hi, @nk54 - Could you elaborate on what kind of test you are looking to write so that we can better understand your use case? |
Beta Was this translation helpful? Give feedback.
-
@mandel-macaque Any thoughts with respect to test runners in VS? |
Beta Was this translation helpful? Give feedback.
-
Hello, thanks for being fast to answer ! @drasticactions yea I know, so if it's the standard platform. Why don't we have the Standard folder in MAUI Library to write an implementation for Standard project ? If I don't have a folder Standard in the Platforms project. I have to to dirty things. Create a folder (so I will have to look for /Platforms/Android-Windows-Tizen-iOS-MacCatalyst but also have to look to /Standard. Every dev would expect to find services at the same place) I will have to specify a different namespace to avoid ambiguity. I will have to do things like
Every time I register a service, I will have to do that. And if I don't want my Standard implementation to be in Android assembly,
=> IMO this feels more like a misunderstanding of how to lay out code rather than something that would need yet another abstraction within MAUI to handle. I think you are right and wrong. Because as it is, few people will bother with MAUI library or unit test. Because too much work and the feeling to fight against Visual Studio. A workaround would be to set the CSPROJ by hand and set the folder to link for each platform. But not easy for everyone. |
Beta Was this translation helpful? Give feedback.
-
Hey, it depends how far can I get. The first steps would be to test my ViewModels, some extensions method, some helpers, some services etc. I would love to have a MUI project for testing purpose (which handle test by platform : you don't need to create a project to test MAUI Platforms/*) Finaly, I would enjoy being able to write integration test : launch the app in an emulator, perform some actions, take some screenshots. |
Beta Was this translation helpful? Give feedback.
-
@nk53 All other code outside of Platforms can be compiled as NET6 and add net60; to your . If you want a folder that is specific ONLY to net6, you can add the following to your csproj: <ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<Compile Include="Platforms\Net60\**\*.cs" />
</ItemGroup> |
Beta Was this translation helpful? Give feedback.
-
Description
Hello,
I want to add UnitTest to my MAUI project. What I need to do is to add ".NET6.0" to the target frameworks.
I followed https://www.youtube.com/watch?v=C9vIDLQwc7M
A video of our famous Gerald Versluis :)
Previously I had this:
If I had net.7.0;
I have an error while registering my services : the compiler is looking for MyServiceImplementation in a Platforms/PlatformNameHere and it doesn't find any.
Maybe we should be able to create a folder "default" or "classic" or "core" or "base" i don't know. Where you can declare service that are used as fallback service when no platform specific service is found. Or it could also be used when targeting .NET only instead of .NET Android .NET iOS etc.
Look the last screenshot : it finds an implementation for each platform except the classic one.
I don't want to include the MyServiceNET7 into the assembly MauiAndroid where I already have MyServiceNET7Android.
Public API Changes
No public API changes: only improvment
Intended Use-Case
I want to be able to unit test my MAUI project with ease
Beta Was this translation helpful? Give feedback.
All reactions