Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Targeting core .NET SDK is not supported #6

Open
rafalka opened this issue Dec 11, 2023 · 5 comments
Open

Targeting core .NET SDK is not supported #6

rafalka opened this issue Dec 11, 2023 · 5 comments

Comments

@rafalka
Copy link

rafalka commented Dec 11, 2023

Description

First of all: thank you for great job with porting this lib to MAUI.

Unfortunately this port has serious architecture issue:
Not all classes are exported when targeting core (ie net7.0 instead ofnet7.0-android) .NET SDK breaks compilation of project which uses them.

This issue blocks any possibility of unit testing of MAUI app.

Steps to Reproduce

  1. Open samples/Sample/Sample.csproj
  2. Add net7.0 to TargetFrameworks
  3. Try to compile

Expected Behavior

Project will compile

Actual Behavior

Several compilation errors related with missing CornersTransformation, GrayscaleTransformation, ....

Basic Information

  • Version with issue: 1.0.3
  • Last known good version: none
  • Platform: Core

Screenshots

N/A

Reproduction Link / Code

N/A

@microspaze
Copy link
Owner

@rafalka I'm sorry I have no idea why do you need the Sample project to support net7.0 or net8.0. The Sample project is a consumer project which must target to a specific OS platform. The FFImageLoading.Maui project is referenced by the FFImageLoading.Tests project which is only for unit-testing. So I add net7.0 and net8.0 support for FFImageLoading.Maui project, but it also has some tricky walkaround not fully support. If you have some specific reason for this need, you can tell me here.

@rafalka
Copy link
Author

rafalka commented Feb 5, 2024

Hi @microspaze,
This issue is not about a sample project but about missing support for non-platform .NET SDKs.
Sample project was just an example how to reproduce this issue.

In real life you want to create a unit tests for your MAUI app, so this app need to compiled as a library and must support the core .NET.
Unfortunately using FFImageLoading breaks that due to missing some symbols which are only available in platform specific runtimes.

@michal-ziolkowski-dev
Copy link

michal-ziolkowski-dev commented Feb 7, 2024

We have the same problem, to support that we can add some compile condition to exclude Image in test configuration, or add suport by adding this library into platform lib implementation. It's not best solutions and i after that we create many redundant code

@rafalka
Copy link
Author

rafalka commented Feb 7, 2024

@michal-ziolkowski-dev: Alternatively you can create stubs form missing classes/methods which will be compiled only on dotnet core:

namespace FFImageLoading
{
    public class ImageService
    {
        public IConfiguration Configuration => null;

        public void InvalidateMemoryCache() { }
        public Task InvalidateCacheAsync(CacheType all = CacheType.All) => Task.CompletedTask;

        public Task InvalidateCacheEntryAsync(string source, CacheType all = CacheType.All, bool ignore = false) => Task.CompletedTask;

        public Work.TaskParameter LoadUrl(string toString) => null;
    }


}

namespace FFImageLoading.Work
{
    public static class TaskParameterExtensions
    {
        public static TaskParameter Preload(this TaskParameter parameter, ImageService _) => parameter;
    }
}



namespace FFImageLoading.Transformations
{
    public class CornersTransformation : ITransformation
    {
        public double TopLeftCornerSize { get; set; }
        public double TopRightCornerSize { get; set; }
        public double BottomLeftCornerSize { get; set; }
        public double BottomRightCornerSize { get; set; }
        public double CropWidthRatio { get; set; }
        public double CropHeightRatio { get; set; }
        public CornerTransformType CornersTransformType { get; set; }

        public CornersTransformation(double cornersSize, CornerTransformType cornersTransformType)
        {
        }

        public CornersTransformation()
        {
            throw new NotImplementedException();
        }

        public IBitmap Transform(IBitmap sourceBitmap, string path, ImageSourceType sourceType, bool isPlaceholder, string key)
        {
            throw new NotImplementedException();
        }

        public string Key { get; }
    }

    public class CircleTransformation : ITransformation
    {

        public double BorderSize { get; set; }

        public string BorderHexColor { get; set; }
        public IBitmap Transform(IBitmap sourceBitmap, string path, ImageSourceType sourceType, bool isPlaceholder, string key)
        {
            throw new NotImplementedException();
        }

        public string Key { get; }
    }
}

@michal-ziolkowski-dev
Copy link

@rafalka works for me on the lates version 1.0.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants