polyadic / funcky

Funcky is a Functional Library for C#
https://polyadic.github.io/funcky
Apache License 2.0
19 stars 3 forks source link

UseWithArgumentNamesAnalyzer: Named Parameters are not allowed in expression trees #742

Closed FreeApophis closed 1 year ago

FreeApophis commented 1 year ago

The following does not compile with error:

error CS0853: An expression tree may not contain a named argument specification

This real example uses AutoMap:

CreateMap<ArticleWithCalculation, Article>()
    .ForCtorParam(nameof(Artikel.PriceCalculation), a => a.MapFrom(
        s => s.Article.Match(
            none: PriceCalculation.NotFound, 
            some: article => article.CatalogType.ConvertPriceCalculation(): ))

If you remove none and some, it will trigger our λ1003 warning:

warning λ1003: Add argument name for argument 'none'

Solution: