Easy dotnet conventions to verify#139
Easy dotnet conventions to verify#139tehraninasab wants to merge 29 commits intonblockchain:masterfrom
Conversation
Add tests for DefiningEmptyStringsWithDoubleQuotes function.
Implement DefiningEmptyStringsWithDoubleQuotes function.
Add tests for ProjFilesNamingConvention function.
Implement ProjFilesNamingConvention function.
Add tests for NotFollowingNamespaceConvention function.
Implement NotFollowingNamespaceConvention function.
Add more tests for NotFollowingNamespaceConvention fn.
Fix NotFollowingNamespaceConvention function.
756f364 to
275d6d1
Compare
Add one more test for NotFollowingNamespaceConvention function.
Function DoesNamespaceInclude doesn't working on *.cs namespace.
21f3749 to
b0acb0c
Compare
| [<Test>] | ||
| let DefiningEmptyStringsWithDoubleQuotes1() = | ||
| let fileInfo = | ||
| (FileInfo( |
| [<Test>] | ||
| let DefiningEmptyStringsWithDoubleQuotes2() = | ||
| let fileInfo = | ||
| (FileInfo( |
| [<Test>] | ||
| let ProjFilesNamingConvention2() = | ||
| let fileInfo = | ||
| (FileInfo( |
| ) | ||
| )) | ||
|
|
||
| Assert.That(ProjFilesNamingConvention fileInfo, Is.EqualTo true) |
There was a problem hiding this comment.
Isn't it easier to use Assert.True?
| [<Test>] | ||
| let ProjFilesNamingConvention1() = | ||
| let fileInfo = | ||
| (FileInfo( |
| ) | ||
| )) | ||
|
|
||
| Assert.That(ProjFilesNamingConvention fileInfo, Is.EqualTo false) |
src/FileConventions/Library.fs
Outdated
| let ProjFilesNamingConvention(fileInfo: FileInfo) = | ||
| printfn "%s" fileInfo.FullName | ||
| false | ||
| let regex = new Regex("(.*)\..*proj$") |
There was a problem hiding this comment.
no need for new keyword
src/FileConventions/Library.fs
Outdated
| printfn "%s" fileInfo.FullName | ||
| false | ||
| let regex = new Regex("(.*)\..*proj$") | ||
| assert (regex.IsMatch fileInfo.FullName) |
There was a problem hiding this comment.
not sure about this but I think paren is not needed
There was a problem hiding this comment.
it is needed; because assert doesn't receive 2 currified arguments
There was a problem hiding this comment.
assert is for debug mode only, are we sure it should be used here?
There was a problem hiding this comment.
it is needed; because
assertdoesn't receive 2 currified arguments
Not sure because it compiles without them 🤔
There was a problem hiding this comment.
@aarani you're right, they should use Fsdk's Misc.BetterAssert
| ) | ||
| )) | ||
|
|
||
| Assert.That(NotFollowingNamespaceConvention fileInfo, Is.EqualTo true) |
| [<Test>] | ||
| let NamespaceConvention1() = | ||
| let fileInfo = | ||
| (FileInfo( |
| [<Test>] | ||
| let NamespaceConvention2() = | ||
| let fileInfo = | ||
| (FileInfo( |
| ) | ||
| )) | ||
|
|
||
| Assert.That(NotFollowingNamespaceConvention fileInfo, Is.EqualTo false) |
src/FileConventions/Library.fs
Outdated
| let NotFollowingNamespaceConvention(fileInfo: FileInfo) = | ||
| printfn "%s" fileInfo.FullName | ||
| false | ||
| assert (fileInfo.FullName.EndsWith(".fs")) |
| <ItemGroup> | ||
| <PackageReference Include="Mono.Posix" Version="7.1.0-final.1.21458.1" /> | ||
| <PackageReference Include="Mono.Unix" Version="7.1.0-final.1.21458.1" /> | ||
| <PackageReference Include="Fsdk" Version="0.6.0--date20230821-0702.git-5488853" /> |
src/FileConventions/Library.fs
Outdated
|
|
||
| let ymlAssertionError = "Bug: file should be a .yml file" | ||
| let projAssertionError = "Bug: file should be a proj file" | ||
| let fsxAssertionError = "Bug: file was not a F#/C# source file" |
There was a problem hiding this comment.
@Mersho if it's an error about F# or C# files, then why do you call it "Fsx Assertion Error"?
1342e1d to
6e74482
Compare
Using RemoveEmptyEntries for split & removing extra parans & Regex does not require a new keyword & string formatting has been corrected.
Add tests for NotFollowingConsoleAppConvention() function.
Ensure that projects that aren't console applications don't have source files with console methods. Co-authored-by: Parham <parhaamsaremi@gmail.com>
Add tests for NotFollowingConsoleAppConvention function and we fix ConsoleAppConvention2 test so that project name does not contradict new tests.
Fix NotFollowingConsoleAppConvention() function.
Add tests for async project, Async.RunSynchronously only allowed in console applications.
Fix NotFollowingConsoleAppConvention() function.
83803e8 to
e124a91
Compare
Add test for NotFollowingNamespaceConvention fn.
A .fs/fsx file might not have a namespace sometimes.
`Contains()` method catches a lot of false-positives and not suitable for this situation so we used regex. Co-authored-by: Parham <parhaamsaremi@gmail.com>
Fix `DefiningEmptyStringsWithDoubleQuotes()` function by using regex insted of `Contains()`. Co-authored-by: Parham <parhaamsaremi@gmail.com>
10b55f8 to
5358b96
Compare
Finding printf and console methods in files & removed printf methods used for debugging purposes & added file filter to ReturnAllProjectSourceFile.
The new dotnetFileConvention.fsx script detects empty strings, wrong namespace usage, and incorrect printf methods on non-console applications.
8fb77c7 to
18b828e
Compare
|
@Mersho CI is still red |
I don't have access to re-run CI, do you think I should re-push? |
Ask Zahra to give you access. The telegram channel is meant for this king of things.
Next time you face a problem like this, just repush while you wait for someone to give you perms; you shouldn't need to depend on me for this kind of small things :) |
BTW, I say "Next time" because I'm going to re-run that CI now, but this shouldn't mean that you don't need to ask for Zahra's perms anymore. |
|
@Mersho the next CI issue might be a permissions problem because Zahra changed her username, I think. Let's workaround this by just opening a new PR from your account. |
|
The pull request has been superseded by a newer one |
Working on #122.