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

Version 2.4 and .NET 4.7 #280

Closed
Hanno11 opened this issue May 1, 2017 · 14 comments
Closed

Version 2.4 and .NET 4.7 #280

Hanno11 opened this issue May 1, 2017 · 14 comments
Milestone

Comments

@Hanno11
Copy link

Hanno11 commented May 1, 2017

The version 2.4 don't work with my project, based on .NET 4.7 + C# 7.0, version 2.3 does.
The problems are releated to the now integrated tuples in .NET 4.7
Greetings
Hanno

@atifaziz
Copy link
Member

atifaziz commented May 1, 2017

When you say it doesn't work, can you share more details, like the compilation errors you're getting?

@Hanno11
Copy link
Author

Hanno11 commented May 1, 2017

Hi, here a little more information
It happens in a function with multiple return values. Till .NET 4.7 you needed to include the tuple lib. In my .NET 4.7 I don't need it anymore.
Here the code

      private async Task<(bool ret, bool excludeOutDated)>
         ReadRealStatus(Request request, Status status, List<EPGEvent> epgEventsUI)
      {
         var result = await UdpSocketDriver.QueryAwait(Commands.GetCurrent);
         var currentServiceInformation = XmlConverter.ExtractData<CurrentServiceInformation>(result);
         if (currentServiceInformation == null)
         {
            await SendBack(request);
            return (false, true);
         }
         ReadMuteVolume(currentServiceInformation, status);
         var excludeOutDated = !string.IsNullOrEmpty(currentServiceInformation.ActualChannel.ProviderName);
         epgEventsUI.Clear();
         if (currentServiceInformation.MediaEvents != null)
            epgEventsUI.AddRange(UtilitiesDb.ConvertEpgEventDbs2EpgEvents(currentServiceInformation.MediaEvents.AllEvents,
               excludeOutDated));
         return (true, excludeOutDated);
      }

And the call of the function, line 81:

            var ret = await ReadRealStatus(request, status, epgEventsUI);

Here with the colored errors:
image

Error messages from visual

Severity	Code	Description	Project	File	Line	Suppression State
Error	CS8137	Cannot define a class or member that utilizes tuples because the compiler required type 'System.Runtime.CompilerServices.TupleElementNamesAttribute' cannot be found. Are you missing a reference?	DreamboxDriver	C:\work\JRiver\SmartHome\DreamboxDriver\CommandQueues\DeviceStatus.cs	111	Active
Error	CS8179	Predefined type 'System.ValueTuple`2' is not defined or imported	DreamboxDriver	C:\work\JRiver\SmartHome\DreamboxDriver\CommandQueues\DeviceStatus.cs	111	Active
Error	CS8179	Predefined type 'System.ValueTuple`2' is not defined or imported	DreamboxDriver	C:\work\JRiver\SmartHome\DreamboxDriver\CommandQueues\DeviceStatus.cs	81	Active
Error	CS8179	Predefined type 'System.ValueTuple`2' is not defined or imported	DreamboxDriver	C:\work\JRiver\SmartHome\DreamboxDriver\CommandQueues\DeviceStatus.cs	81	Active
Error	CS8179	Predefined type 'System.ValueTuple`2' is not defined or imported	DreamboxDriver	C:\work\JRiver\SmartHome\DreamboxDriver\CommandQueues\DeviceStatus.cs	81	Active
Error	CS8179	Predefined type 'System.ValueTuple`2' is not defined or imported	DreamboxDriver	C:\work\JRiver\SmartHome\DreamboxDriver\CommandQueues\DeviceStatus.cs	81	Active
Error	CS8179	Predefined type 'System.ValueTuple`2' is not defined or imported	DreamboxDriver	C:\work\JRiver\SmartHome\DreamboxDriver\CommandQueues\DeviceStatus.cs	81	Active
Error	CS8179	Predefined type 'System.ValueTuple`2' is not defined or imported	DreamboxDriver	C:\work\JRiver\SmartHome\DreamboxDriver\CommandQueues\DeviceStatus.cs	119	Active
Error	CS8179	Predefined type 'System.ValueTuple`2' is not defined or imported	DreamboxDriver	C:\work\JRiver\SmartHome\DreamboxDriver\CommandQueues\DeviceStatus.cs	127	Active

Any more question? Feel free to ask
Greetings
Hannno

@atifaziz
Copy link
Member

atifaziz commented May 2, 2017

Thanks, @Hanno11. I'm afraid since there's no independent download available for .NET 4.7 currently besides having a Windows 10 machine with Creator Update, it's very hard to reproduce this issue. Your help in digging to the bottom of the issue would be much appreciated. The code you have shared has nothing to do with MoreLINQ, but if I understand correctly, upgrading MoreLINQ to 2.4.0 causes those seemingly unrelated errors in your project. I have a feeling this has less to do with MoreLINQ and more with one of the following:

[Umbrella] ValueTuple library work

@Hanno11
Copy link
Author

Hanno11 commented May 2, 2017

Hi,
correct, in this code moreLINQ is not used. The trouble comes surely not directly from moreLINQ, but from the collision of the tuple libs. Perhaps all will be solved, when the creator update is available everywhere

@Hanno11 Hanno11 closed this as completed May 2, 2017
@aienabled
Copy link

.NET 4.7 is available now for Windows 7 SP1 and newer Windows versions.
https://blogs.msdn.microsoft.com/dotnet/2017/05/02/announcing-the-net-framework-4-7-general-availability/

@willson556
Copy link

willson556 commented Jun 24, 2017

The solution to this will be to remove System.ValueTuple as a dependency when targeting 4.7. Until then, MoreLINQ is incompatible with 4.7. This should be reopened and the package reference somehow removed in the 4.7 version.

EDIT: This is a decent reference for conditional references: https://blogs.msmvps.com/punitganshani/2015/06/21/5-steps-to-targeting-multiple-net-frameworks/

@atifaziz
Copy link
Member

@willson556 This should really be solved by the System.ValueTuple package instead of every dependent having to do it. The issue I see with adding the 4.7 target to MoreLINQ is that anyone wanting to build and contribute to the project will also need to have 4.7 installed, which is setting the bar pretty high for what seems to be an artificial requirement.

@ljani
Copy link

ljani commented Aug 22, 2017

The solution seems to be explicitly installing System.ValueTuple version 4.4.0 instead of the declared 4.3.0 version of the dependency. I don't know if 4.3.1 fixes this.

4.4.0 was released along with .NET Core 2.0 13 days ago.

Also NuGet defaults to installing the lowest available version of dependencies unless explicitly specified in .csproj, so you'll end up with 4.3.0 as morelinq declares it as the minimum requirement.

@atifaziz
Copy link
Member

The solution seems to be explicitly installing System.ValueTuple version 4.4.0

Looks like they've addressed the issue in System.ValueTuple 4.4.0 as I see the assembly for 4.7 having types forwarded to mscorlib (that should do the unification):

.class extern forwarder System.Runtime.CompilerServices.TupleElementNamesAttribute
{
    .assembly extern 'mscorlib'
}

.class extern forwarder System.TupleExtensions
{
    .assembly extern 'mscorlib'
}

.class extern forwarder System.ValueTuple
{
    .assembly extern 'mscorlib'
}

.class extern forwarder System.ValueTuple`1
{
    .assembly extern 'mscorlib'
}

.class extern forwarder System.ValueTuple`2
{
    .assembly extern 'mscorlib'
}

.class extern forwarder System.ValueTuple`3
{
    .assembly extern 'mscorlib'
}

.class extern forwarder System.ValueTuple`4
{
    .assembly extern 'mscorlib'
}

.class extern forwarder System.ValueTuple`5
{
    .assembly extern 'mscorlib'
}

.class extern forwarder System.ValueTuple`6
{
    .assembly extern 'mscorlib'
}

.class extern forwarder System.ValueTuple`7
{
    .assembly extern 'mscorlib'
}

.class extern forwarder System.ValueTuple`8
{
    .assembly extern 'mscorlib'
}

@ljani Thanks for bringing this to my attention; I'm re-opening this issue.

I don't know if 4.3.1 fixes this.

I'm afraid it doesn't.

@atifaziz atifaziz reopened this Aug 22, 2017
@atifaziz atifaziz added this to the 2.7.0 milestone Aug 22, 2017
atifaziz added a commit to atifaziz/MoreLINQ that referenced this issue Aug 23, 2017
Helps with type unification under .NET 4.7 since System.ValueTuple
types are also available from mscorlib there. See morelinq#280 for more
details.
@atifaziz
Copy link
Member

atifaziz commented Aug 23, 2017

The morelinq.2.7.0-ci-20170823T1226.nupkg package references System.ValueTuple 4.4.0. As I don't have .NET 4.7, I would appreciate that those who do, could take the package for a spin and give feedback if it resolves this issue or not. Thanks!

@atifaziz
Copy link
Member

morelinq.2.7.0-ci-20170823T1226.nupkg is now also published as MoreLinq 2.7 beta 1 on nuget.org. Again, testing and feedback against .NET 4.7 and write respect to this issue would be appreciated.

@ljani
Copy link

ljani commented Aug 24, 2017

MoreLinq 2.7 beta 1 on nuget.org.

Working fine here.

For some reason it'll fail the very first rebuild after changing 2.6.0 to 2.7.0-beta-1 (or vice versa, but it succeeds in that case), but the second rebuild will pass without any problems, but it's MSBuild's problem and I've seen similar behavior with other packages as well.

@atifaziz
Copy link
Member

@ljani Thanks for testing and confirming that it works. 👍

For some reason it'll fail the very first rebuild after changing 2.6.0 to 2.7.0-beta-1

Perhaps missing a dotnet restore just after upgrading?

@ljani
Copy link

ljani commented Aug 24, 2017

Perhaps missing a dotnet restore just after upgrading?

Yeah, something like that, though 2.0 stated that dotnet restore is now an implicit command and it says it's restoring packages when building. Might VS' problem, dunno.

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

5 participants