Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

"Could not resolve type reference" for some iterator methods in VS2015 #47

@billings7

Description

@billings7

Any iterator methods which are explicitly implemented from an interface, and the interface contains multiple generic type arguments, causes a "Could not resolve type reference" error in the re-writer when built in Visual Studio 2015.
For example:

public class TestYield : IEnumerable<Tuple<int, int>>
{
    IEnumerator<Tuple<int, int>> IEnumerable<Tuple<int, int>>.GetEnumerator()
    {
        yield break;
    }

    IEnumerator IEnumerable.GetEnumerator()
    {
        yield break;
    }
}

fails with Could not resolve type reference: [TestContracts]TestContracts.TestYield.<System-Collections-Generic-IEnumerable<System-Collections-Generic-KeyValuePair<System-Int32\,System-Int32>>-GetEnumerator>d__0.

The root cause of this is the type name parser used by the re-writer to read attributes does not support reading type names with escaped characters. The Rosyln compiler is adding an IteratorStateMachineAttribute to the method pointing to a type with the name <System-Collections-Generic-IEnumerable<System-Collections-Generic-KeyValuePair<System-Int32,System-Int32>>-GetEnumerator>d__0, and the comma in the generic arguments gets escaped with a backslash in the IL.

Pull request incoming.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions