Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for F# projects and use optimized directory traversals #48

Merged
merged 2 commits into from
Aug 28, 2024

Conversation

baronfel
Copy link
Contributor

@baronfel baronfel commented Aug 27, 2024

Hi! This implements support for F# projects as well as using some new modern .NET directory traversals to speed up the traversal that was happening before. I've tested this on my own F# projects and it works great!

Results:

>dotnet run E:\code\LanguageServerProtocol -t
Writing files with encoding: utf-8
Pick lowest version (not max): False
VersionComparison: Default
WARNING: You are about to make changes to the following project files:
 Ionide.LanguageServerProtocol.fsproj
 Ionide.LanguageServerProtocol.Tests.fsproj
 MetaModelGenerator.fsproj
Are you sure you want to continue? [y/n]
yProcessing references for E:\code\LanguageServerProtocol\src\Ionide.LanguageServerProtocol.fsproj...
 Found new reference: DotNet.ReproducibleBuilds 1.1.1
 Found new reference: Ionide.KeepAChangelog.Tasks 0.1.8
 Found new reference: Newtonsoft.Json 13.0.1
 Found new reference: FSharp.Core 6.0.0
 Found new reference: StreamJsonRpc 2.16.36
Processing references for E:\code\LanguageServerProtocol\tests\Ionide.LanguageServerProtocol.Tests.fsproj...
 Found new reference: BenchmarkDotNet 0.13.1
 Found new reference: Expecto 10.2.1
 Found new reference: Expecto.FsCheck 10.2.1
 Found new reference: FsCheck 2.16.5
 Found new reference: Fabulous.AST 1.0.0-pre12
 Found new reference: GitHubActionsTestLogger 2.0.1
 Found new reference: Microsoft.NET.Test.Sdk 17.2.0
 Found new reference: YoloDev.Expecto.TestSdk 0.14.3
Processing references for E:\code\LanguageServerProtocol\tools\MetaModelGenerator\MetaModelGenerator.fsproj...
 Found new reference: Argu 6.2.4
Writing 1 refs to Directory.Packages.props to E:\code\LanguageServerProtocol\Directory.Packages.props...
Processing Complete.

@@ -8,7 +8,7 @@ namespace CentralisedPackageConverter;
public static class Output
{
public static void InfoLine(string message) => InfoLine(message, Array.Empty<object>());
public static void InfoLine(string message, params object[] args) => AnsiConsole.MarkupLine(Markup.Escape(message), args);
public static void InfoLine(string message, params object[] args) => AnsiConsole.MarkupLine(message, args);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was required because the [green](project file path[/] markup wasn't being rendered.

Comment on lines +404 to +413
if (condition != String.Empty)
{
Output.InfoLine(" Found new reference: {0} {1} with Condition {2}",
package, version.ToFullString(), condition);
}
else
{
Output.InfoLine(" Found new reference: {0} {1}",
package, version.ToFullString());
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did some simple if/elses here to remove dangling string formats for cases where there were no conditions.

Comment on lines +25 to +39
return new FileSystemEnumerable<FileInfo>(
directory: directory.FullName,
transform: (ref FileSystemEntry entry) => new FileInfo(entry.ToFullPath()),
options: new EnumerationOptions { RecurseSubdirectories = searchOption == SearchOption.AllDirectories }
)
{
ShouldIncludePredicate = (ref FileSystemEntry entry) =>
{
return !entry.IsDirectory && AllowedFileExtensions.Contains(Path.GetExtension(entry.FileName).ToString());
},
ShouldRecursePredicate = (ref FileSystemEntry entry) =>
{
return !ExcludesRegex.IsMatch(entry.FileName);
},
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type is hyper-optimized and the existing traversal tests still pass after the change.

@Webreaper Webreaper merged commit 056f4d7 into Webreaper:master Aug 28, 2024
1 check passed
@Webreaper
Copy link
Owner

Merged - thank you for your contribution! :)

@Webreaper Webreaper mentioned this pull request Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants