Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
50fe215
FileConventions: add failing test
tehraninasab Aug 1, 2023
186213e
FileConventions: implement the function
tehraninasab Aug 1, 2023
2ebd2b5
FileConventions: add failing test
tehraninasab Aug 1, 2023
cc82850
FileConventions: implement the function
tehraninasab Aug 3, 2023
a0272d6
FileConventions: add failing test
tehraninasab Aug 7, 2023
482d4d6
FileConventions: implement the function
tehraninasab Aug 7, 2023
5f06394
FileConventions.Test: add failing test
tehraninasab Aug 7, 2023
12f4d0b
FileConventions: fix the function
tehraninasab Aug 7, 2023
b0acb0c
FileConventions: add failing test
Mersho Aug 17, 2023
7823ab2
FileConventions: fix csharp namespace
Mersho Aug 17, 2023
9b8afb3
FileConventions: add failing test
Mersho Aug 17, 2023
21f3749
FileConventions: `Contains()` is not suitable here
Mersho Aug 17, 2023
81bfb57
FileConventions: use BetterAssert() & update Fsdk
Mersho Aug 21, 2023
e124a91
FileConventions(.Test): applying f# standard style
Mersho Aug 21, 2023
eb5f76c
FileConventions: add failing test
Mersho Aug 21, 2023
885a60a
FileConventions: fix the function
Mersho Aug 21, 2023
4e0c6e1
FileConventions: add failing test
Mersho Aug 22, 2023
6e80056
FileConvention: fix the function
Mersho Aug 22, 2023
46f3dae
FileConventions: add failing test
Mersho Aug 22, 2023
45e298b
FileConvention: fix the function
Mersho Aug 22, 2023
c190f9c
FileConventions(.Test): fix proj file indent
Mersho Aug 28, 2023
d49a99c
FileConvention: properly naming variables
Mersho Aug 28, 2023
19b442d
FileConventions: add failing test
Mersho Aug 29, 2023
e6fc879
FileConvention: fix the function
Mersho Aug 29, 2023
5358b96
FileConventions.Test: add failing test
Mersho Aug 23, 2023
ce4c0c6
FileConventions: fix empty string false-positives
Mersho Aug 23, 2023
18b828e
FileConventions: load Helpers.fs first
Mersho Aug 24, 2023
1fd7576
FileConventions: improvements to Library.fs
Mersho Aug 24, 2023
a326d09
FileConventions: dotnetFileConvention
Mersho Aug 24, 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 @@ -9,7 +9,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
79 changes: 79 additions & 0 deletions scripts/dotnetFileConvention.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/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"

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: dotnetFileConvention.fsx [projectFolder(optional)]"

Environment.Exit 1

let rootDir = DirectoryInfo args.[0]

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

let allProjFiles =
ReturnAllProjectSourceFile 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 @@ -4,6 +4,7 @@ open System.IO
open System

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#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 @@ -4,8 +4,9 @@ open System
open System.IO

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#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

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
3 changes: 2 additions & 1 deletion scripts/inconsistentVersionsInFSharpScripts.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ open System.IO
open System.Linq

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#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 @@ -3,9 +3,10 @@
open System.IO

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#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 @@ -4,9 +4,10 @@ open System
open System.IO

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#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 @@ -4,9 +4,10 @@ open System
open System.IO

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#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 @@ -4,9 +4,10 @@ open System
open System.IO

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#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/unpinnedDotnetPackageVersions.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ open System
open System.IO

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#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 @@ -4,9 +4,10 @@ open System
open System.IO

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#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 @@ -4,9 +4,10 @@ open System
open System.IO

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#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/unpinnedNugetPackageReferenceVersions.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ open System
open System.IO

#r "nuget: Mono.Unix, Version=7.1.0-final.1.21458.1"
#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
4 changes: 2 additions & 2 deletions scripts/wrapLatestCommitMsg.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ open System
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"

#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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
namespace Foo.Baz
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
namespace Bar
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using System;

namespace Foo;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
namespace Foo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
namespace Baz
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
namespace FooBuzz
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
printf "Hello"
Loading