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

Adding .NET Core Support #13

Closed
mangelarilla opened this issue Jun 20, 2016 · 35 comments
Closed

Adding .NET Core Support #13

mangelarilla opened this issue Jun 20, 2016 · 35 comments
Assignees

Comments

@mangelarilla
Copy link

Well, not much to add to the title. Started a console project with this new .NET Core approach, added Colorful.Console nuget and got the incompatibility error once added.

I just let you know the incompatibility in case it is trivial to fix, but I don't think this is an urgent issue 👍

@tomakita tomakita self-assigned this Jun 22, 2016
@tomakita
Copy link
Owner

Thanks for letting me know. Is there a specific error message that you see? I believe this may be related the discussion here: #12

@mangelarilla
Copy link
Author

Nothing concrete sadly, just a generic "this nuget is not compatible" message pointing to the project.json lines where this nuget reference appears.

I'll take a look and see if I can also help.

@tomakita
Copy link
Owner

I see. Thanks for the info, and thanks for taking a look! I will also look into this when I can find some spare time.

@RehanSaeed
Copy link
Collaborator

RehanSaeed commented Jul 1, 2016

I just merged a PR to support .NET Core 1.0 and netstandard 1.3. I marked the version as 2.0 and now some testing can begin before releasing.

Colorful.Console should totally work on OSX and Linux now! However, the colours will not change on these platforms as the P/Invoke signatures are obviously different. This bit of code needs to be filled in to change colours on those platforms. I have no experience of OSX and Linux P/Invoke so I'm at a loss there.

Even without colours changing on these platforms I still think it may be worth a release as it still works on Windows and you still have Figlet font text.

When we release, we should tweet the .NET Core team and get some visibility of the project.

@RehanSaeed
Copy link
Collaborator

Someone in this StackOverflow wrote a method to get the nearest ConsoleColor based on a System.Drawing.Color. We could execute this method on OSX or Linux.

I'm not too clued up on how the ColorMapper class works. I'm a bit confused as to why the method signature MapColor(ConsoleColor oldColor, Color, newColor is not as simple as SetColour(Color color). @tomakita Can you help?

@tomakita
Copy link
Owner

tomakita commented Jul 2, 2016

@RehanSaeed good question. I'll check this out later today, and will update this thread.

@RehanSaeed
Copy link
Collaborator

We should also probably put a try catch into MapColor and fall back to picking the closest ConsoleColor. We can't assume that PInvoke will work anymore.

@tomakita
Copy link
Owner

tomakita commented Jul 2, 2016

Good point -- will do.

@RehanSaeed
Copy link
Collaborator

@RehanSaeed RehanSaeed changed the title Doesn't Work with .NET Core Adding .NET Core Support Jul 2, 2016
@tomakita
Copy link
Owner

tomakita commented Jul 2, 2016

I've just implemented the "nearest match" functionality (d20b38c)! A word of warning, though: I don't have access to an OSX or Linux machine, so I'm not quite sure how well this will work. I did write a test to make sure that the nearest match is actually correct (at least for a handful of test-case colors), but I'm still not 100% confident.

I've just read through the issue you opened on the CoreFX page. I wonder when .NET Core will support System.Drawing.Color? I'll also look into those two ConsolePal classes -- I had never heard of those until now.

@giggio
Copy link

giggio commented Aug 16, 2016

Is this progressing? I would very much like to use it in a .NET Core App.

@RehanSaeed
Copy link
Collaborator

@giggio The current master branch should work on Mac and Linux without being so colourful but needs testing.

@tomakita
Copy link
Owner

@giggio Like @RehanSaeed said, the master branch should work on Mac and Linux, but it will only display the standard colors when writing in color. Is it not working for you? As I mentioned in my last post in this thread, I haven't actually tested this library on Mac or Linux, so I'm not certain that it does work. If it isn't working for you on either of those platforms, that would be interesting for us to know.

@giggio
Copy link

giggio commented Aug 18, 2016

Tests don't work, you have a dependency on net461. The same goes for the Example App.
I tried some of the code for the sample app. I got some errors.

This is from:

            string[] storyFragments = new string[]
            {
               "John went to the store.",
               "He wanted to buy fruit.",
               "The security guard wouldn't let him buy fruit.",
               "John didn't like being harrassed about buying fruit.",
               "He went to another fruit store.",
               "At the other fruit store, he selected a ripe piece of fruit.",
               "A security guard came by and deselected the piece of fruit.",
               "John selected it again.",
               "He was determined to buy fruit.",
               "Until 7 PM, when the store closed."
            };

            int r = 225;
            int g = 255;
            int b = 250;
            for (int i = 0; i < 10; i++)
            {
               Console.WriteLine(storyFragments[i], Color.FromArgb(r, g, b));

               r -= 18;
               b -= 9;
            }

1

It happens on other parts as well.

@tomakita
Copy link
Owner

tomakita commented Aug 23, 2016

Thanks for the info! Sorry for the delay -- I'm looking into this now. I've discovered that there's an element in the Colorful.Console xproj file that may be causing this problem:

<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>

Unfortunately, I don't actually know what this does (we target more than 4.6.1, so I'm not sure what this means), and can't find any useful documentation. I have some ideas, though, and will update this thread once I've done some testing.

@tomakita
Copy link
Owner

@giggio I believe this should be fixed now (b1897f1). Let me know if it isn't, and I'll keep working on it.

@giggio
Copy link

giggio commented Aug 23, 2016

@tomakita
Copy link
Owner

@giggio Ok, thanks for the feedback. We use xUnit for our tests, and it isn't compatible with any versions of .NET Standard, yet, so the Tests project isn't cross-platform at the moment.

As for the Example project, when I try to add .NET Standard as a framework in the project.json file, I get an unhelpful compilation error about .NET Standard 1.3 not being compatible with my target runtime. I'm guessing that this has something to do with the fact that the Example application is a console application, as that's the only difference between it and the Colorful.Console project itself.

I'm going to wait until .NET Core 1.1 is released before doing any further work on cross-platform compatibility. In the meantime, if you'd like to submit a PR related to cross-platform compatibility, feel free!

Thanks again for the feedback.

@tomakita
Copy link
Owner

@giggio By the way, I apologize for the poor support you're getting from me on this issue. I feel like I need to get a better low-level understanding of .NET Core in order to address this issue, but I don't have time right now. My only solace is that, the more mature .NET Core gets, the better the documentation will become, so the barrier to entry will eventually become low enough for me to participate!

@giggio
Copy link

giggio commented Aug 23, 2016

Sure, no problem.
BTW, xUnit is already compatible: http://xunit.github.io/docs/getting-started-dotnet-core.html

@RehanSaeed
Copy link
Collaborator

@giggio xUnit is compatible but right now, you cannot run tests against both .NET Core and .NET Framework separately. You have to pick one and run tests against that. My understanding is that this will change in the next version.

@tomakita
Copy link
Owner

Just to give a quick update: I haven't forgotten about adding .NET Core support -- I'm waiting for .NET Core to support .NET Standard 2.0, and will make the change at that time. I was hoping that this would happen in .NET Core 1.1, but it looks like it only supports .NET Standard 1.6.1. Let's hope this changes in .NET Core 1.2!

@giggio
Copy link

giggio commented Oct 31, 2016

@tomakita what API are you depending on to use .NET Standard 2.0?

@tomakita
Copy link
Owner

@giggio We depend on System.Drawing.

@wonea
Copy link

wonea commented Mar 2, 2017

Would ImageSharp work as a replacement for System.Drawing? I use it for Color in my projects.

https://github.com/JimBobSquarePants/ImageSharp

@tomakita
Copy link
Owner

@wonea Thanks for the reminder. We've experimented with ImageSharp, and I don't remember why, but we ended up not being able to use it. That was over a year ago, though, so I'll look into it again.

@jrr
Copy link

jrr commented May 27, 2017

The future is here, and .NET Core 2.0 Preview 1 is available with System.Drawing
https://www.microsoft.com/net/core/preview

@tomakita
Copy link
Owner

Thanks for letting me know. Looking through dotnet/core#640, I don't feel comfortable making the switch to Preview 1. Preview 2 is supposed to be released at the end of June, so I'll check that out when it's released.

@RehanSaeed
Copy link
Collaborator

The Serilog project has implemented ANSI 256 color themes. Read this blog post to see how they did it. There is a limited colour pallete of 256 colours, I'm not sure how that would work if System.Drawing was used.

@tomakita
Copy link
Owner

Thanks @RehanSaeed, we're looking into this as we speak: #24 !

@PoisonousJohn
Copy link

PoisonousJohn commented Oct 12, 2017

Hey! .NetCore 2.0 has been released.

Right now I tried to use the package and got following errors:

/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605: Detected package downgrade: System.Collections from4.3.0 to 4.0.11. Reference the package directly from the project to select a different version.
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605:  gameClientEventSender (>= 1.0.0) -> Colorful.Console (>= 1.1.0) -> NETStandard.Library (>= 1.6.1) -> System.Collections (>= 4.3.0)
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605:  gameClientEventSender (>= 1.0.0) -> Colorful.Console (>= 1.1.0) -> System.Collections (>= 4.0.11)
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605: Detected package downgrade: System.Collections.Concurrent from 4.3.0 to 4.0.12. Reference the package directly from the project to select a different version.
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605:  gameClientEventSender (>= 1.0.0) -> Colorful.Console (>= 1.1.0) -> NETStandard.Library (>= 1.6.1) -> System.Collections.Concurrent (>= 4.3.0)
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605:  gameClientEventSender (>= 1.0.0) -> Colorful.Console (>= 1.1.0) -> System.Collections.Concurrent (>= 4.0.12)
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605: Detected package downgrade: System.Console from 4.3.0 to 4.0.0. Reference the package directly from the project to select a different version.
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605:  gameClientEventSender (>= 1.0.0) -> Colorful.Console (>= 1.1.0) -> NETStandard.Library (>= 1.6.1) -> System.Console (>= 4.3.0)
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605:  gameClientEventSender (>= 1.0.0) -> Colorful.Console (>= 1.1.0) -> System.Console (>= 4.0.0)
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605: Detected package downgrade: System.Diagnostics.Debug from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version.
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605:  gameClientEventSender (>= 1.0.0) -> Colorful.Console (>= 1.1.0) -> NETStandard.Library (>= 1.6.1) -> System.Diagnostics.Debug (>= 4.3.0)
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605:  gameClientEventSender (>= 1.0.0) -> Colorful.Console (>= 1.1.0) -> System.Diagnostics.Debug (>= 4.0.11)
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605: Detected package downgrade: System.IO.FileSystem from 4.3.0 to 4.0.1. Reference the package directly from the project to select a different version.
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605:  gameClientEventSender (>= 1.0.0) -> Colorful.Console (>= 1.1.0) -> NETStandard.Library (>= 1.6.1) -> System.IO.FileSystem (>= 4.3.0)
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605:  gameClientEventSender (>= 1.0.0) -> Colorful.Console (>= 1.1.0) -> System.IO.FileSystem (>= 4.0.1)
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605: Detected package downgrade: System.Linq from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version.
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605:  gameClientEventSender (>= 1.0.0) -> Colorful.Console (>= 1.1.0) -> NETStandard.Library (>= 1.6.1) -> System.Linq (>= 4.3.0)
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605:  gameClientEventSender (>= 1.0.0) -> Colorful.Console (>= 1.1.0) -> System.Linq (>= 4.1.0)
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605: Detected package downgrade: System.Runtime.Extensions from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version.
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605:  gameClientEventSender (>= 1.0.0) -> Colorful.Console (>= 1.1.0) -> NETStandard.Library (>= 1.6.1) -> System.Runtime.Extensions (>= 4.3.0)
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605:  gameClientEventSender (>= 1.0.0) -> Colorful.Console (>= 1.1.0) -> System.Runtime.Extensions (>= 4.1.0)
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605: Detected package downgrade: System.Runtime.InteropServices from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version.
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605:  gameClientEventSender (>= 1.0.0) -> Colorful.Console (>= 1.1.0) -> NETStandard.Library (>= 1.6.1) -> System.Runtime.InteropServices (>= 4.3.0)
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605:  gameClientEventSender (>= 1.0.0) -> Colorful.Console (>= 1.1.0) -> System.Runtime.InteropServices (>= 4.1.0)
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605: Detected package downgrade: System.Text.RegularExpressions from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version.
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605:  gameClientEventSender (>= 1.0.0) -> Colorful.Console (>= 1.1.0) -> NETStandard.Library (>= 1.6.1) -> System.Text.RegularExpressions (>= 4.3.0)
/home/jp/git/gameClientEventSender/gameClientEventSender.csproj : error NU1605:  gameClientEventSender (>= 1.0.0) -> Colorful.Console (>= 1.1.0) -> System.Text.RegularExpressions (>= 4.1.0)

@tomakita
Copy link
Owner

Thanks to @JamieG, Colorful.Console should now work under .NET Core 2.0!

Colorful.Console Release 1.2.0
NuGet package

@giggio
Copy link

giggio commented Oct 23, 2017

@tomakita I can see you are taking a dependency on .NET Core 2.0. You should change that to support .NET Standard 2.0. This way any platform that supports the .NET Standard will be able to run it, not only .NET Core.

@tomakita
Copy link
Owner

Will do today after work -- thanks for the tip!

@tomakita
Copy link
Owner

@JamieG has very generously made this change! Let me know how it goes.

NuGet package

@tomakita tomakita closed this as completed Nov 3, 2017
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

7 participants