Skip to content

Commit

Permalink
FileConventions: implement the function
Browse files Browse the repository at this point in the history
Implement NotFollowingNamespaceConvention function.
  • Loading branch information
tehraninasab authored and Mersho committed Aug 17, 2023
1 parent a0272d6 commit 482d4d6
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/FileConventions/Library.fs
Original file line number Diff line number Diff line change
Expand Up @@ -411,5 +411,31 @@ let ProjFilesNamingConvention(fileInfo: FileInfo) =
fileName <> parentDirectoryName

let NotFollowingNamespaceConvention(fileInfo: FileInfo) =
printfn "%s" fileInfo.FullName
false
assert (fileInfo.FullName.EndsWith(".fs"))

let fileName = Path.GetFileNameWithoutExtension fileInfo.FullName

let parentDirectoryName =
Path.GetDirectoryName fileInfo.FullName |> Path.GetFileName

printfn
"File name: %s, Parent directory name: %s"
fileName
parentDirectoryName

if parentDirectoryName <> "src"
&& fileInfo.FullName.Contains
$"{Path.DirectorySeparatorChar}src{Path.DirectorySeparatorChar}" then
let fileText = File.ReadLines fileInfo.FullName

if fileText.Any() then
let firstLine = fileText.First()

if firstLine.Contains "namespace" then
firstLine.Contains parentDirectoryName |> not
else
false
else
false
else
false

0 comments on commit 482d4d6

Please sign in to comment.