-3

I have a dotnet standard 2.0 project that implements an interface. I want to include a System.Windows.Point point in the interface, but I don't have access to System.Windows.Point in dotnet standard 2.0.

I have three projects:

  • a dotnet 6.0 project
  • a dotnet framework 4.7 project
  • a project they both need to target (so .net standard 2.0 because that is compatible with both)
    • I DON'T have access to System.Windows.Point
    • I hold the interface that the other two projects use (the one that needs System.Windows.Point)

Is there a way to stub the Point class? so I would write a file that looks something like:

public interface MyInterface
{
    System.Windows.Point myPoint {get;}
}

namespace System.Windows
{
#if NETSTANDARD2_0

    [Obsolete("Warning: You aren't really using System.Windows.Point. This is a stub for .Net Standard 2.0")]
    public class Point
    {
        public double X { get; }
        public double Y { get; }

        public Point(double x, double y)
        {
            X = x;
            Y = y;
        }
    }
#endif
}

My example doesn't quite work - it creates a new, confusing System.Windows.Point class, so when I use the interface, it can't take regular System.Windows.Points, because it's not the real System.Windows.Point class. Not surprising, but....

bwall
  • 984
  • 8
  • 22
  • 1
    Is there some reason you can't use the [System.Drawing.Point](https://learn.microsoft.com/en-us/dotnet/api/system.drawing.point?view=net-7.0) struct? – Mark Benningfield Aug 31 '23 at 15:37
  • @MarkBenningfield, I looked into using System.Drawing.Point or System.Drawing.PointF, I guess I'm just a little nervous to tweak the interface - the 4.7 packages was already released with it. But that's definitely an option :) – bwall Aug 31 '23 at 15:44

0 Answers0