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

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

Closed
fubar-coder opened this issue Dec 5, 2018 · 12 comments
Closed
Labels
area-System.Threading question Answer questions and provide assistance, not an issue with source code or documentation.

Comments

@fubar-coder
Copy link
Contributor

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
Copy link
Member

Was renamed to ManualResetValueTaskSourceCore<TResult>

@benaadams
Copy link
Member

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

@fubar-coder
Copy link
Contributor Author

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

@stephentoub
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).

@jkotas jkotas closed this as completed Dec 5, 2018
@pkanavos
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
Copy link
Member

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
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
Copy link

shawty commented Dec 13, 2018

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

@ericnewton76
Copy link

from the visual studio blog:

Now all the squiggles are gone, and the program is correct. But if you try compiling and running it, you get an embarassing number of errors. That’s because we messed up a bit, and didn’t get the previews of .NET Core 3.0 and Visual Studio 2019 perfectly aligned. Specifically, there’s an implementation type that async iterators leverage that’s different from what the compiler expects.

I just wanted to say kudos for acknowledging the mistake and pointing to a clear workaround for the time being.

@rossbuggins
Copy link

I'm seeing:
CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator'
on async IAsynEnumerable methods. Got VS2019 preview2 and core 3 preview.

@rossbuggins
Copy link

I'm seeing:
CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator'
on async IAsynEnumerable methods. Got VS2019 preview2 and core 3 preview.

using .net core 3 3.0.100-preview-010184 sorted this

@vip32
Copy link

vip32 commented Mar 6, 2019

Note that this boilerplate is no longer necessary in Preview 2 (ie. using preview2 versions of the compiler/VS and of Core

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Threading question Answer questions and provide assistance, not an issue with source code or documentation.
Projects
None yet
Development

No branches or pull requests

9 participants