ME-MarvinE / XCalendar

A plugin for .NET providing an API for representing a calendar along with fully customisable calendar controls for Xamarin Forms and .NET MAUI
MIT License
300 stars 36 forks source link

Maybe we need add net8.0 framework to maui library. #170

Closed migueBarrera closed 9 months ago

migueBarrera commented 11 months ago

I have a maui project that has unit tests. To have unit tests, the maui project has to support net-8. You can learn more about this here: https://youtu.be/C9vIDLQwc7M?t=169

We have to add to the maui library, the net8 framework. This solution is inspired by how this library does it: https://github.com/hjam40/Camera.MAUI/blob/master/Camera.MAUI/Camera.MAUI.csproj.

Any alternative?

Now, by default, If you have unit tests and add XCalendar, it adds conditions in the csproj like this:

`

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-ios'">
  <PackageReference Include="XCalendar.Maui">
    <Version>4.5.3</Version>
  </PackageReference>
</ItemGroup>

`

Also if you don't hide the using of xcalendar in #if Android, it will fail to run the tests.

@ME-MarvinE . If you see this as a good solution. I can do it myself.

ME-MarvinE commented 11 months ago

This seems like a good change to make, however there are some things I don't understand about the changes that will be made.

I understood the changes in the video you linked but not this part:

Any alternative?

Now, by default, If you have unit tests and add XCalendar, it adds conditions in the csproj like this:

`

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-ios'">
  <PackageReference Include="XCalendar.Maui">
    <Version>4.5.3</Version>
  </PackageReference>
</ItemGroup>

@ME-MarvinE . If you see this as a good solution. I can do it myself.

Are you saying the above code snippet is what is added currently or will it be added after the changes?

Also if you don't hide the using of xcalendar in #if Android, it will fail to run the tests.

What do you mean by "Hide the using of XCalendar in #If Android"? I don't see any preprocessor directives in our current csproj files or the csproj file of the repo you linked. And when you say "Using of XCalendar" do you mean the package reference?

scheidtdav commented 9 months ago

I am currently facing this as well and may be able to clarify what @migueBarrera means. With the current version of XCalendar you will need to have the following added to your csproj file:

<ItemGroup>
  <PackageReference Include="XCalendar.Core" Version="4.5.5" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
  <PackageReference Include="XCalendar.Maui" Version="4.5.3" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
  <PackageReference Include="XCalendar.Maui" Version="4.5.3" />
</ItemGroup>

This is necessary because a unit-testable MAUI project like the above would target net8, net8-android and net8-ios. After the change, this whole section would be replaced by just

<ItemGroup>
  <PackageReference Include="XCalendar.Maui" Version="4.5.3" />
</ItemGroup>

(Note the change from XCalendar.Core to XCalendar.Maui).

ME-MarvinE commented 9 months ago

Ah thanks for explaining, definitely something to implement then.