Skip to content

Null coalesce not working #209

Description

@Xriuk

Having a code like this:

public class Price{
  public decimal Amount { get; set; }
}

public Product{
  public Price? Price { get; set; }

  [Projectable(AllowBlockBody = true, NullConditionalRewriteSupport = NullConditionalRewriteSupport.Ignore)]
  public decimal GetCost(){
    return Price?.Amount ?? 0m;
  }
}

Which gets compiled to this:

...
public decimal ...Product_GetCost(){
  return Price.Amount ?? 0m;
}
...

Which triggers the compilation error:

CS0019 - Operator '??' cannot be applied to operands of type 'decimal' and 'decimal'

In this case it should get cast to the Nullable type (decimal?).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions