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

ManualResetValueTaskSourceLogic`1 missing in System.Private.CoreLib #21379

Closed
fubar-coder opened this Issue Dec 5, 2018 · 8 comments

Comments

Projects
None yet
6 participants
@fubar-coder
Copy link

fubar-coder commented Dec 5, 2018

I used .NET Core 3.0.0-preview-27122-01, win10-x64 (downloaded from dot.net) and tried to build this example application:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace TestCsConsole
{
    class Program
    {
        static async Task Main(string[] args)
        {
            await foreach (var num in GetNumbersAsync())
            {
                Console.WriteLine(num);
            }
        }

        private static async IAsyncEnumerable<int> GetNumbersAsync()
        {
            foreach (var num in Enumerable.Range(0, 10))
            {
                yield return num;
            }
        }
    }
}

The build fails with the following errors:

1>------ Neues Erstellen gestartet: Projekt: TestCsConsole, Konfiguration: Debug Any CPU ------
1>C:\Program Files\dotnet\sdk\3.0.100-preview-009812\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(142,5): message NETSDK1057: Sie arbeiten mit einer Vorschauversion des .NET Core SDK. Sie können die SDK-Version über eine Datei "global.json" im aktuellen Projekt definieren. Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=869452.
1>Program.cs(19,9,25,10): error CS0656: Missing compiler required member 'System.Threading.Tasks.ManualResetValueTaskSourceLogic`1..ctor'
1>Program.cs(19,9,25,10): error CS0656: Missing compiler required member 'System.Threading.Tasks.ManualResetValueTaskSourceLogic`1.GetResult'
1>Program.cs(19,9,25,10): error CS0656: Missing compiler required member 'System.Threading.Tasks.ManualResetValueTaskSourceLogic`1.GetStatus'
1>Program.cs(19,9,25,10): error CS0656: Missing compiler required member 'System.Threading.Tasks.ManualResetValueTaskSourceLogic`1.get_Version'
1>Program.cs(19,9,25,10): error CS0656: Missing compiler required member 'System.Threading.Tasks.ManualResetValueTaskSourceLogic`1.OnCompleted'
1>Program.cs(19,9,25,10): error CS0656: Missing compiler required member 'System.Threading.Tasks.ManualResetValueTaskSourceLogic`1.Reset'
1>Program.cs(19,9,25,10): error CS0656: Missing compiler required member 'System.Threading.Tasks.ManualResetValueTaskSourceLogic`1.SetException'
1>Program.cs(19,9,25,10): error CS0656: Missing compiler required member 'System.Threading.Tasks.ManualResetValueTaskSourceLogic`1.SetResult'
1>Program.cs(19,9,25,10): error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.IStrongBox`1.get_Value'
1>Program.cs(19,9,25,10): error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.IStrongBox`1.Value'
1>Die Erstellung des Projekts "TestCsConsole.csproj" ist abgeschlossen -- FEHLER.
========== Alles neu erstellen: 0 erfolgreich, 1 fehlerhaft, 0 übersprungen ==========

Project file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <LangVersion>8.0</LangVersion>
    <NullableReferenceTypes>true</NullableReferenceTypes>
  </PropertyGroup>

</Project>
@benaadams

This comment has been minimized.

Copy link
Collaborator

benaadams commented Dec 5, 2018

Was renamed to ManualResetValueTaskSourceCore<TResult>

@benaadams

This comment has been minimized.

Copy link
Collaborator

benaadams commented Dec 5, 2018

Ah, looks like mismatch between C#8 and the runtime? /cc @stephentoub

@fubar-coder

This comment has been minimized.

Copy link

fubar-coder commented Dec 5, 2018

I was also unable to find ManualResetValueTaskSourceCore in the System.Private.CoreLib assembly.

@stephentoub

This comment has been minimized.

Copy link
Member

stephentoub commented Dec 5, 2018

It's not missing exactly, but like @benaadams said things are just out-of-sync between the compiler and library in Preview 1. The compiler is looking for the old design (ManualResetValueTaskSourceLogic<T> and IStrongBox<T>), while the libraries include the approved API surface area (ManualResetValueTaskSourceCore<T>), and we didn't have time to get the compiler updated. You just need to include a bit of boilerplate in your app, e.g.

namespace System.Threading.Tasks
{
    using System.Runtime.CompilerServices;
    using System.Threading.Tasks.Sources;

    internal struct ManualResetValueTaskSourceLogic<TResult>
    {
        private ManualResetValueTaskSourceCore<TResult> _core;
        public ManualResetValueTaskSourceLogic(IStrongBox<ManualResetValueTaskSourceLogic<TResult>> parent) : this() { }
        public short Version => _core.Version;
        public TResult GetResult(short token) => _core.GetResult(token);
        public ValueTaskSourceStatus GetStatus(short token) => _core.GetStatus(token);
        public void OnCompleted(Action<object> continuation, object state, short token, ValueTaskSourceOnCompletedFlags flags) => _core.OnCompleted(continuation, state, token, flags);
        public void Reset() => _core.Reset();
        public void SetResult(TResult result) => _core.SetResult(result);
        public void SetException(Exception error) => _core.SetException(error);
    }
}

namespace System.Runtime.CompilerServices
{
    internal interface IStrongBox<T> { ref T Value { get; } }
}

[update by jcouv:] Note that this boilerplate is no longer necessary in Preview 2 (ie. using preview2 versions of the compiler/VS and of Core).

@pkanavos

This comment has been minimized.

Copy link

pkanavos commented Dec 6, 2018

The code compiles but enumerating Enumerable.Range(0, 10) ends after only 2 iterations. This doesn't happen with an array

@stephentoub

This comment has been minimized.

Copy link
Member

stephentoub commented Dec 6, 2018

The code compiles but enumerating Enumerable.Range(0, 10) ends after only 2 iterations. This doesn't happen with an array

This is a compiler bug: dotnet/roslyn#31268

@shawty

This comment has been minimized.

Copy link

shawty commented Dec 13, 2018

This is also manifesting itself in the following way:

MSB6006 "csc.exe" exited with code -2146232797. AsyncStreams C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets 52

Just for reference.

@shawty

This comment has been minimized.

Copy link

shawty commented Dec 13, 2018

Sorry, I meant to add that comment to "31268" in the post above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment