最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - Compiler magic to universally replace default implementations of .Equals(...) and .GetHashCode() for record types - Stack O

programmeradmin7浏览0评论

Does anyone know of any compiler magic I could apply to universally replace the implementations of .Equals(...) and .GetHashCode() in record types? I want to modify these such that when they contain an ImmutableArray<> they use sequence equality (.SequenceEqual(...)) instead of reference equality.

Currently, .Equals(...) and .GetHashCode() need to be manually provided on every record type that contains an ImmutableArray<> in order for the designed value equality to work. This process is labour-intensive, prone to error, adds a maintenance overhead, and makes the signal (other aspects of the record) hard to see among the noise (boiler-plate implementation). This is in spite of ImmutableArray<> being (as the name suggests) immutable.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论