Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e6a52df
FileConventions: add failing test
tehraninasab Aug 1, 2023
e4fd6ad
FileConventions: implement the function
tehraninasab Aug 1, 2023
73f1616
FileConventions: add failing test
tehraninasab Aug 1, 2023
bef4d60
FileConventions: implement the function
tehraninasab Aug 3, 2023
564ab28
FileConventions: add failing test
tehraninasab Aug 7, 2023
643ce01
FileConventions: implement the function
tehraninasab Aug 7, 2023
9181d0a
FileConventions.Test: add failing test
tehraninasab Aug 7, 2023
e04bf9f
FileConventions: fix the function
tehraninasab Aug 7, 2023
ab96c16
FileConventions: add failing test
Mersho Aug 17, 2023
09693ec
FileConventions: fix csharp namespace
Mersho Aug 17, 2023
4123980
FileConventions: add failing test
Mersho Aug 17, 2023
6d9ab78
FileConventions: `Contains()` is not suitable here
Mersho Aug 17, 2023
7a16e38
FileConventions: use BetterAssert() & update Fsdk
Mersho Aug 21, 2023
041607a
FileConventions(.Test): applying f# standard style
Mersho Aug 21, 2023
953a7a0
FileConventions: add failing test
Mersho Aug 21, 2023
9600b42
FileConventions: fix the function
Mersho Aug 21, 2023
94760ed
FileConventions: add failing test
Mersho Aug 22, 2023
f3ae4e2
FileConvention: fix the function
Mersho Aug 22, 2023
e667a77
FileConventions: add failing test
Mersho Aug 22, 2023
d01c584
FileConvention: fix the function
Mersho Aug 22, 2023
78304d1
FileConventions(.Test): fix proj file indent
Mersho Aug 28, 2023
a5e3c73
FileConvention: properly naming variables
Mersho Aug 28, 2023
da16e2d
FileConventions: add failing test
Mersho Aug 29, 2023
859afb8
FileConvention: fix the function
Mersho Aug 29, 2023
f2a5d0e
FileConventions.Test: add failing test
Mersho Aug 23, 2023
383ba0f
FileConventions: fix empty string false-positives
Mersho Aug 23, 2023
68cf748
FileConventions: load Helpers.fs first
Mersho Aug 24, 2023
7800c42
FileConventions: improvements to Library.fs
Mersho Aug 24, 2023
e4f22be
scripts: add dotNetFileConventions.fsx
Mersho Aug 24, 2023
541168e
FileConventions: improvements to Library.fs
Mersho Sep 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/checkCommits1by1.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ open System.Net.Http.Headers
#r "nuget: FSharp.Data, Version=5.0.2"
open FSharp.Data

#r "nuget: Fsdk, Version=0.6.0--date20230214-0422.git-1ea6f62"
#r "nuget: Fsdk, Version=0.6.0--date20230821-0702.git-5488853"

open Fsdk
open Fsdk.Process
Expand Down
2 changes: 1 addition & 1 deletion scripts/compileFSharpScripts.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
open System
open System.IO

#r "nuget: Fsdk, Version=0.6.0--date20230214-0422.git-1ea6f62"
#r "nuget: Fsdk, Version=0.6.0--date20230821-0702.git-5488853"
#load "../src/FileConventions/Helpers.fs"

Fsdk
Expand Down
80 changes: 80 additions & 0 deletions scripts/dotnetFileConventions.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env -S dotnet fsi

open System
open System.IO
open System.Text.RegularExpressions

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#r "nuget: Fsdk, Version=0.6.0--date20230821-0702.git-5488853"
#r "nuget: YamlDotNet, Version=16.1.3"

open Fsdk
open Fsdk.Process

#load "../src/FileConventions/Helpers.fs"
#load "../src/FileConventions/Library.fs"

open FileConventions
open Helpers

let args = Misc.FsxOnlyArguments()

if args.Length > 1 then
Console.Error.WriteLine
"Usage: dotnetFileConventions.fsx [projectFolder(optional)]"

Environment.Exit 1

let rootDir = DirectoryInfo args.[0]

// DefiningEmptyStringsWithDoubleQuotes
let allSourceFiles = ReturnAllProjectSourceFiles rootDir [ "*.cs"; "*.fs" ] true
printfn "%A" (String.Join("\n", allSourceFiles))

let allProjFiles =
ReturnAllProjectSourceFiles rootDir [ "*.csproj"; "*.fsproj" ] true

for sourceFile in allSourceFiles do
let isStringEmpty = DefiningEmptyStringsWithDoubleQuotes sourceFile

if isStringEmpty then
failwith(
sprintf
"%s file: Contains empty strings specifed with \"\" , you should use String.Empty()"
sourceFile.FullName
)


// ProjFilesNamingConvention

for projfile in allProjFiles do
let isWrongProjFile = ProjFilesNamingConvention projfile

if isWrongProjFile then
failwith(
sprintf
"%s file: Project file or Project directory is incorrect!\n
Fix: use same name on .csproj/.fsproj on parrent project directory"
projfile.FullName
)

// notfollowingnamespaceconvention
for sourcefile in allSourceFiles do
let iswrongnamespace = NotFollowingNamespaceConvention sourcefile

if iswrongnamespace then
failwith(sprintf "%s file: has wrong namespace!" sourcefile.FullName)

// NotFollowingConsoleAppConvention
for projfile in allProjFiles do
let isWrongConsoleApplication =
NotFollowingConsoleAppConvention projfile true

printfn "%A" projfile

if isWrongConsoleApplication then
failwith(
sprintf
"%s project: Should not contain console methods or printf"
projfile.FullName
)
1 change: 1 addition & 0 deletions scripts/eofConvention.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ open System

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#r "nuget: YamlDotNet, Version=16.1.3"
#r "nuget: Fsdk, Version=0.6.0--date20230821-0702.git-5488853"

#load "../src/FileConventions/Helpers.fs"
#load "../src/FileConventions/Library.fs"
Expand Down
3 changes: 2 additions & 1 deletion scripts/executableConvention.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ open System.IO

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#r "nuget: YamlDotNet, Version=16.1.3"
#load "../src/FileConventions/Library.fs"
#r "nuget: Fsdk, Version=0.6.0--date20230821-0702.git-5488853"
#load "../src/FileConventions/Helpers.fs"
#load "../src/FileConventions/Library.fs"

let rootDir = Path.Combine(__SOURCE_DIRECTORY__, "..") |> DirectoryInfo
let currentDir = Directory.GetCurrentDirectory() |> DirectoryInfo
Expand Down
2 changes: 1 addition & 1 deletion scripts/gitPush1by1.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ open System.Threading
#r "System.Configuration"
open System.Configuration

#r "nuget: Fsdk, Version=0.6.0--date20230214-0422.git-1ea6f62"
#r "nuget: Fsdk, Version=0.6.0--date20230821-0702.git-5488853"

open Fsdk
open Fsdk.Process
Expand Down
2 changes: 1 addition & 1 deletion scripts/inconsistentNugetVersionsInDotNetProjects.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ open System.IO
#r "System.Core.dll"
#r "System.Xml.Linq.dll"

#r "nuget: Fsdk, Version=0.6.0--date20230214-0422.git-1ea6f62"
#r "nuget: Fsdk, Version=0.6.0--date20230821-0702.git-5488853"

open Fsdk

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ open System.IO
#r "System.Core.dll"
#r "System.Xml.Linq.dll"

#r "nuget: Fsdk, Version=0.6.0--date20230214-0422.git-1ea6f62"
#r "nuget: Fsdk, Version=0.6.0--date20230821-0702.git-5488853"
#r "nuget: Microsoft.Build, Version=16.11.0"
#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#r "nuget: YamlDotNet, Version=16.1.3"

#load "../src/FileConventions/Library.fs"
#load "../src/FileConventions/Helpers.fs"
#load "../src/FileConventions/Library.fs"
#load "../src/FileConventions/NugetVersionsCheck.fs"
#load "../src/FileConventions/CombinedVersionCheck.fs"

Expand Down
3 changes: 2 additions & 1 deletion scripts/inconsistentNugetVersionsInFSharpScripts.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ open System.Linq

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#r "nuget: YamlDotNet, Version=16.1.3"
#r "nuget: Fsdk, Version=0.6.0--date20230821-0702.git-5488853"

#load "../src/FileConventions/Library.fs"
#load "../src/FileConventions/Helpers.fs"
#load "../src/FileConventions/Library.fs"

let rootDir = Path.Combine(__SOURCE_DIRECTORY__, "..") |> DirectoryInfo
let currentDir = Directory.GetCurrentDirectory() |> DirectoryInfo
Expand Down
3 changes: 2 additions & 1 deletion scripts/inconsistentVersionsInGitHubCI.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ open System.IO

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#r "nuget: YamlDotNet, Version=16.1.3"
#r "nuget: Fsdk, Version=0.6.0--date20230821-0702.git-5488853"

#load "../src/FileConventions/Library.fs"
#load "../src/FileConventions/Helpers.fs"
#load "../src/FileConventions/Library.fs"

let rootDir = Path.Combine(__SOURCE_DIRECTORY__, "..") |> DirectoryInfo

Expand Down
3 changes: 2 additions & 1 deletion scripts/mixedLineEndings.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ open System.IO

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#r "nuget: YamlDotNet, Version=16.1.3"
#r "nuget: Fsdk, Version=0.6.0--date20230821-0702.git-5488853"

#load "../src/FileConventions/Library.fs"
#load "../src/FileConventions/Helpers.fs"
#load "../src/FileConventions/Library.fs"

let rootDir = Path.Combine(__SOURCE_DIRECTORY__, "..") |> DirectoryInfo

Expand Down
3 changes: 2 additions & 1 deletion scripts/nonVerboseFlagsInGitHubCIAndScripts.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ open System.IO

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#r "nuget: YamlDotNet, Version=16.1.3"
#r "nuget: Fsdk, Version=0.6.0--date20230821-0702.git-5488853"

#load "../src/FileConventions/Library.fs"
#load "../src/FileConventions/Helpers.fs"
#load "../src/FileConventions/Library.fs"

let rootDir = Path.Combine(__SOURCE_DIRECTORY__, "..") |> DirectoryInfo

Expand Down
3 changes: 2 additions & 1 deletion scripts/shebangConvention.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ open System.IO

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#r "nuget: YamlDotNet, Version=16.1.3"
#r "nuget: Fsdk, Version=0.6.0--date20230821-0702.git-5488853"

#load "../src/FileConventions/Library.fs"
#load "../src/FileConventions/Helpers.fs"
#load "../src/FileConventions/Library.fs"

let rootDir = Path.Combine(__SOURCE_DIRECTORY__, "..") |> DirectoryInfo

Expand Down
3 changes: 2 additions & 1 deletion scripts/unpinnedDotnetToolInstallVersions.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ open System.IO

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#r "nuget: YamlDotNet, Version=16.1.3"
#r "nuget: Fsdk, Version=0.6.0--date20230821-0702.git-5488853"

#load "../src/FileConventions/Library.fs"
#load "../src/FileConventions/Helpers.fs"
#load "../src/FileConventions/Library.fs"

let rootDir = Path.Combine(__SOURCE_DIRECTORY__, "..") |> DirectoryInfo

Expand Down
3 changes: 2 additions & 1 deletion scripts/unpinnedGitHubActionsImageVersions.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ open System.IO

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#r "nuget: YamlDotNet, Version=16.1.3"
#r "nuget: Fsdk, Version=0.6.0--date20230821-0702.git-5488853"

#load "../src/FileConventions/Library.fs"
#load "../src/FileConventions/Helpers.fs"
#load "../src/FileConventions/Library.fs"

let rootDir = Path.Combine(__SOURCE_DIRECTORY__, "..") |> DirectoryInfo

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ open System.IO

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#r "nuget: YamlDotNet, Version=16.1.3"
#r "nuget: Fsdk, Version=0.6.0--date20230821-0702.git-5488853"

#load "../src/FileConventions/Library.fs"
#load "../src/FileConventions/Helpers.fs"
#load "../src/FileConventions/Library.fs"

let rootDir = Path.Combine(__SOURCE_DIRECTORY__, "..") |> DirectoryInfo

Expand Down
3 changes: 2 additions & 1 deletion scripts/unpinnedNugetPackageReferenceVersionsInProjects.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ open System.IO

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#r "nuget: YamlDotNet, Version=16.1.3"
#r "nuget: Fsdk, Version=0.6.0--date20230821-0702.git-5488853"

#load "../src/FileConventions/Library.fs"
#load "../src/FileConventions/Helpers.fs"
#load "../src/FileConventions/Library.fs"

let rootDir = Path.Combine(__SOURCE_DIRECTORY__, "..") |> DirectoryInfo
let currentDir = Directory.GetCurrentDirectory() |> DirectoryInfo
Expand Down
4 changes: 2 additions & 2 deletions scripts/wrapLatestCommitMsg.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ open System.Linq

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#r "nuget: YamlDotNet, Version=16.1.3"
#r "nuget: Fsdk, Version=0.6.0--date20230821-0702.git-5488853"

#load "../src/FileConventions/Helpers.fs"
#load "../src/FileConventions/Library.fs"

#r "nuget: Fsdk, Version=0.6.0--date20230214-0422.git-1ea6f62"

open Fsdk
open Fsdk.Process

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
printf "Hello World"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
printf "Hello World"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
async { do! Async.Sleep(5000) } |> Async.RunSynchronously
printf "Hello World"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<Compile Include="Library.fs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace DummyProjectAsync

module Say =

let delayedHello name =
async { do! Async.Sleep(5000) } |> Async.RunSynchronously
"Delayed Hello"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
printf "Hello World"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<Compile Include="Library.fs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// printf not accepted here
namespace DummyProjectWithWrongConsole

module Say =
let hello name =
printfn "Hello %s" name
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env -S dotnet fsi

open System
open System.IO

let emptyString = String.Empty
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let myString = "\"Hello World\""
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let temp = "Hello World"

match temp with
| "" -> failwith "Empty String"
| _ -> failwith "Non-Empty String"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env -S dotnet fsi

open System
open System.IO

let emptyString = ""
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
namespace Foo.Bar
Loading