Skip to content

Conversation

@dsyme
Copy link
Contributor

@dsyme dsyme commented Jul 11, 2022

Discussing codebase regularity with @psfinaki , here's a script to print a report by analysing all identifiers in an F# project by type.

Sample reports here:

Run using:

dotnet fsi tests/scripts/identifierAnalysisByType.fsx src/FSharp.Build/FSharp.Build.fsproj
dotnet fsi tests/scripts/identifierAnalysisByType.fsx src/Compiler/FSharp.Compiler.Service.fsproj

For example this section of the output shows all the names used for ValReprInfo https://gist.github.com/dsyme/d47f113d7423e3cdc45a2f658c68a1a0

I sometimes think F# should have a feature where you can put an attribute on a type saying "if you have a value of this type, it must be named according to this regular expression". I guess we could adjust this script easily to implement that as a check (so the tool reports warnings based on attributes)

@dsyme
Copy link
Contributor Author

dsyme commented Jul 11, 2022

Note the formulation in tests\scripts\identifierAnalysisByType.fsx can easily be adjusted to write other analyses. Please adapt, copy, play.

The FCS API is far from perfect and things like formatting of types are a bit messy (type abbreviations and other features make that a bit tricky). But we can still extract a lot of useful information from adhoc tools like this.

printfn " %s" (vUse.ToString())
printfn "")

(*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably. I hacked it across from https://github.com/fsprojects/FSharp.Formatting/blob/main/src/fsdocs-tool/ProjectCracker.fs and I think it was all a workaround for something, I'm not sure. Or else maybe it was there to cope with non-standard install locations for dotnet

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW Ionide.ProjInfo is here: https://github.com/ionide/proj-info

It's the project cracking code used by the Ionide tooling for F# in VSCode

@dsyme dsyme merged commit de49e2f into dotnet:main Jul 11, 2022
@dsyme dsyme mentioned this pull request Jul 11, 2022
KevinRansom pushed a commit that referenced this pull request Jul 12, 2022
* ValRepInfoForDisplay added for improved quick info for functions defined in expressions

* Update

* Update QuickInfoTests.fs

* Update QuickInfoTests.fs

* Update

* add identifier analysis script (#13486)

* add identifier analysis script

* add identifier analysis script

* Update fantomas alpha 11 (#13481)

Co-authored-by: Don Syme <[email protected]>
Co-authored-by: Peter Semkin <[email protected]>
Co-authored-by: Don Syme <[email protected]>
Co-authored-by: Florian Verdonck <[email protected]>
Co-authored-by: Petr Semkin <[email protected]>
vzarytovskii added a commit that referenced this pull request Jul 12, 2022
* ValRepInfoForDisplay added for improved quick info for functions defined in expressions

* Update

* Update QuickInfoTests.fs

* Update QuickInfoTests.fs

* Update

* add identifier analysis script (#13486)

* add identifier analysis script

* add identifier analysis script

* Update fantomas alpha 11 (#13481)

* Allow lower-case DU cases when RequireQualifiedAccess is specified (#13432)

* Allow lower-case DU cases when RequireQualifiedAccess is specified

* Fix PR suggestions and Add more testing

* Protect feature under preview version

* Add a NotUpperCaseConstructorWithoutRQA warning to be raised in lang version preview

* Fix formatting

* regularize some names (#13489)

* normalize some names

* format code

* fix build

* Subtraction of two chars, new conversions, and fixes for dynamic operator invocations and QuotationToExpression (#11681)

Co-authored-by: Vlad Zarytovskii <[email protected]>
Co-authored-by: Don Syme <[email protected]>

* Mark backing fields as CompilerGenerated (fixes serialization of fields in FSI multiemit) (#13494)

Co-authored-by: Don Syme <[email protected]>
Co-authored-by: Peter Semkin <[email protected]>
Co-authored-by: Don Syme <[email protected]>
Co-authored-by: Florian Verdonck <[email protected]>
Co-authored-by: Petr Semkin <[email protected]>
Co-authored-by: Edgar Gonzalez <[email protected]>
Co-authored-by: Hadrian Tang <[email protected]>
Co-authored-by: Vlad Zarytovskii <[email protected]>
Co-authored-by: Kevin Ransom (msft) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants