简体   繁体   English

F#中的代码分析

[英]Code analysis in F#

As a C# developer I've benefited from Microsoft's Code Analysis. 作为一名C#开发人员,我从微软的代码分析中受益匪浅。 In F# however, Code Analysis doesn't seem to be an integrated part of the development cycle. 然而,在F#中,代码分析似乎不是开发周期的一个集成部分。 It took me a while to enable CA on an F# project, but this blog helped . 我花了一段时间在F#项目上启用CA,但这篇博客有所帮助 Now that I have CA enabled, it seems to produce "wrong" warnings. 现在我已启用CA,它似乎产生“错误”警告。 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. 此博客演示了两个类型为Acccount的实例,其数量相同,应该相等。 Why does the code analysis then tell me that: 'Account' should define operator '!=' since it implements IComparable? 为什么代码分析会告诉我:“帐户”应该定义运算符'!=',因为它实现了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. 当然,如果这是一个C#类,那么我将不得不跳过所有这些箍,但在F#中,这应该是自动发生的。

I am applying the "Microsoft All Rules" ruleset. 我正在应用“Microsoft All Rules”规则集。 Do these not apply to F#, and if so, is there any ruleset that I should use? 这些不适用于F#,如果是,那么我应该使用哪些规则集?

You can also use FSharpLint in Visual F# Power Tools : 您还可以在Visual F#Power Tools中使用FSharpLint

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM