F#中的代码分析 [英] Code analysis in F#

查看:86
本文介绍了F#中的代码分析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为C#开发人员,我从Microsoft的代码分析中受益。但是,在F#中,代码分析似乎并不是开发周期中不可或缺的一部分。我花了一段时间才能在F#项目上启用CA,但这


As a C# developer I've benefited from Microsoft's Code Analysis. In F# however, Code Analysis doesn't seem to be an integrated part of the development cycle. It took me a while to enable CA on an F# project, but this blog helped. Now that I have CA enabled, it seems to produce "wrong" warnings. For instance, I have a declared a record type as

type Account = {Number : string}

for which I expect structural equality by default. This blog demonstrates that two instances of type Acccount, for which the number is the same, should be equal. Why does the code analysis then tell me that: 'Account' should define operator '!=' since it implements IComparable? For sure, had this been a C# class then I would have to jump through all those hoops, but in F# this should happen automagically.

I am applying the "Microsoft All Rules" ruleset. Do these not apply to F#, and if so, is there any ruleset that I should use?

解决方案

You can also use FSharpLint in Visual F# Power Tools :

这篇关于F#中的代码分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆