Roslyn: Invalid image when compiling this project, caused by use of the elvis operator ?.

Created on 12 Jul 2016  路  1Comment  路  Source: dotnet/roslyn

Version Used: VS2015.3 RTM
CSC Version: Microsoft (R) Visual C# Compiler version 1.3.1.60616

Steps to Reproduce:

  1. git clone -b crash-sample https://github.com/jtheisen/moldinium.git
  2. msbuild
  3. peverify ConsoleApplication1.exe

Expected Behavior:

All Classes and Methods in ConsoleApplication1\bin\Debug\ConsoleApplication1.exe Verified.

Actual Behavior:

[IL]: Error: [C:\Source\Repos\moldinium\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe : IronStone.Moldinium.LiveList+<>c__DisplayClass10_0`1[TSource]::b__2][offset 0x0000013B] Unable to resolve token.

If you remove all the ?. operators from the Select.cs file, the program passes PEVerify.

This happens if you build in debug or release configurations.

More information in this SO post.

4 - In Review Area-Compilers Bug

Most helpful comment

Here is a minimal repro:

``` c#
using System;

public static class LiveList
{
struct WhereInfo
{
public int Key { get; set; }
}

public static void Where<TSource>()
{
    Action subscribe = () =>
    {
        WhereInfo<TSource>? previous = null;

        var previousKey = previous?.Key;
    };
}

public static void Main()
{
}

}
```

>All comments

Here is a minimal repro:

``` c#
using System;

public static class LiveList
{
struct WhereInfo
{
public int Key { get; set; }
}

public static void Where<TSource>()
{
    Action subscribe = () =>
    {
        WhereInfo<TSource>? previous = null;

        var previousKey = previous?.Key;
    };
}

public static void Main()
{
}

}
```

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marler8997 picture marler8997  路  3Comments

OndrejPetrzilka picture OndrejPetrzilka  路  3Comments

DavidArno picture DavidArno  路  3Comments

asvishnyakov picture asvishnyakov  路  3Comments

AdamSpeight2008 picture AdamSpeight2008  路  3Comments