-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backend: use reflectionless default build (for UWP frontend)
It turns out that F#'s (s)printf(n) functions use reflection [1], so UWP's CoreRT compiler/runtime is not happy about it at all [2]; then this is a workaround that uses `String.Format` underneath, except when compiled with a define for stricter compilation. (Compiling with this define will still give us the compile-time safety of sprintf vs String.Format such as checking number of arguments and their types, but without the portability to UWP.) [1] dotnet/corert#6055 (comment) [2] https://stackoverflow.com/q/60350735/544947
- Loading branch information
Showing
30 changed files
with
505 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/usr/bin/env fsharpi | ||
|
||
open System | ||
open System.IO | ||
open System.Linq | ||
|
||
#r "System.Configuration" | ||
#load "InfraLib/Misc.fs" | ||
#load "InfraLib/Process.fs" | ||
#load "InfraLib/Git.fs" | ||
open FSX.Infrastructure | ||
open Process | ||
|
||
let FindInFile (file: FileInfo) | ||
(maybeExcludeItems: Option<seq<FileSystemInfo>>) | ||
(someStrings: seq<string>) | ||
: unit = | ||
let doIt () = | ||
for line in File.ReadLines file.FullName do | ||
for someString in someStrings do | ||
if line.IndexOf someString >= 0 then | ||
printfn "%s: %s" file.FullName line | ||
|
||
match maybeExcludeItems with | ||
| None -> | ||
doIt () | ||
| Some excludeItems -> | ||
if excludeItems.All(fun entryToExclude -> entryToExclude.FullName <> file.FullName) then | ||
doIt () | ||
|
||
let rec FindExcludingDir (dir: DirectoryInfo) | ||
(maybeExcludeItems: Option<seq<FileSystemInfo>>) | ||
(someStrings: seq<string>) | ||
: unit = | ||
let doIt () = | ||
for file in dir.GetFiles() do | ||
if file.Extension.ToLower() <> ".dll" && | ||
file.Extension.ToLower() <> ".exe" && | ||
file.Extension.ToLower() <> ".png" then | ||
FindInFile file maybeExcludeItems someStrings | ||
for subFolder in dir.GetDirectories() do | ||
if subFolder.Name <> ".git" && | ||
subFolder.Name <> "obj" && | ||
subFolder.Name <> "bin" && | ||
subFolder.Name <> "packages" then | ||
FindExcludingDir subFolder maybeExcludeItems someStrings | ||
match maybeExcludeItems with | ||
| None -> | ||
doIt () | ||
| Some excludeItems -> | ||
if excludeItems.All(fun entryToExclude -> entryToExclude.FullName <> dir.FullName) then | ||
doIt () | ||
|
||
let args = Misc.FsxArguments() | ||
|
||
let note = "NOTE: by default, some kind of files/folders will be excluded, e.g.: .git/, packages/, bin/, obj/, *.exe, *.dll, *.png, ..." | ||
|
||
if args.Length < 1 then | ||
Console.Error.WriteLine "Please pass at least 1 argument, with optional flag: find.fsx [-x=someDirToExclude,someFileToExclude] someString" | ||
Console.WriteLine note | ||
Environment.Exit 1 | ||
|
||
let firstArg = args.[0] | ||
|
||
let excludeParticularFileSystemEntries = | ||
if firstArg.StartsWith "--exclude=" || firstArg.StartsWith "-x=" then | ||
firstArg.Substring(firstArg.IndexOf("=")+1) |> Some | ||
else | ||
None | ||
|
||
let startDir = Directory.GetCurrentDirectory() |> DirectoryInfo | ||
match excludeParticularFileSystemEntries with | ||
| None -> | ||
let someStrings = args | ||
FindExcludingDir startDir None someStrings | ||
| Some excludeList -> | ||
let someStrings = args.Skip(1) | ||
let entriesToExclude = | ||
excludeList.Split([|Path.PathSeparator|], StringSplitOptions.RemoveEmptyEntries) | ||
let excludeItems = | ||
seq { | ||
for entry in entriesToExclude do | ||
let dir = entry |> DirectoryInfo | ||
let file = entry |> FileInfo | ||
if dir.Exists then | ||
yield dir :> FileSystemInfo | ||
elif file.Exists then | ||
yield file :> FileSystemInfo | ||
else | ||
failwithf "Directory or file '%s' doesn't exist" dir.FullName | ||
} | ||
FindExcludingDir startDir (Some excludeItems) someStrings | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.