Skip to content

Commit

Permalink
Update dependencies.
Browse files Browse the repository at this point in the history
Wrap text fix.
LINQPad 5 files enumeration works the same as for LINQPad 6.
LPRun 6.14.10
  • Loading branch information
Ivan Ivon committed Jul 19, 2021
1 parent 439306b commit fc8626d
Show file tree
Hide file tree
Showing 24 changed files with 117 additions and 61 deletions.
2 changes: 1 addition & 1 deletion Deploy/buildlpx.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@echo off

set version=6.14.0
set version=6.14.1
set fileName=CsvLINQPadDriver.%version%.lpx

set zip="%ProgramFiles%\7-Zip\7z.exe"
Expand Down
43 changes: 43 additions & 0 deletions Src/CsvLINQPadDriver/Bcl/Extensions/DirectoryExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

using CsvLINQPadDriver.Extensions;

namespace CsvLINQPadDriver.Bcl.Extensions
{
internal static class DirectoryExtensions
{
public static IEnumerable<string> EnumerateFiles(this ICollection<Exception>? exceptions, string path, string searchPattern, SearchOption searchOption)
{
var directories = new Queue<string>(new[] { path });

while (directories.Any())
{
var currentDirectory = directories.Dequeue();

if (searchOption == SearchOption.AllDirectories)
{
try
{
foreach (var directory in Directory.EnumerateDirectories(currentDirectory))
{
directories.Enqueue(directory);
}
}
catch (Exception e)
{
exceptions?.Add(e);
continue;
}
}

foreach (var file in Directory.EnumerateFiles(currentDirectory, searchPattern).SkipExceptions(exceptions))
{
yield return file;
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;

namespace CsvLINQPadDriver.Microsoft.Bcl
namespace CsvLINQPadDriver.Bcl.Extensions
{
internal static class ImmutableExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// https://raw.githubusercontent.com/dotnet/runtime/main/src/libraries/System.Private.CoreLib/src/System/Range.cs
// https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Range.cs

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
Expand Down
2 changes: 1 addition & 1 deletion Src/CsvLINQPadDriver/CodeGen/CsvCSharpCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#if NETCOREAPP
using System.Collections.Immutable;
#else
using CsvLINQPadDriver.Microsoft.Bcl;
using CsvLINQPadDriver.Bcl.Extensions;
#endif

namespace CsvLINQPadDriver.CodeGen
Expand Down
4 changes: 2 additions & 2 deletions Src/CsvLINQPadDriver/ConnectionDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@
<TextBlock>
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Text" Value=""/>
<Setter Property="Text" Value="{x:Static this:ConnectionDialog.WrapText}"/>
<Setter Property="ToolTip" Value="Turn on word wrap (Ctrl+W)"/>
<Style.Triggers>
<DataTrigger Binding="{Binding TextWrapping, ElementName=FilesTextBox}" Value="Wrap">
<Setter Property="Text" Value=""/>
<Setter Property="Text" Value="{x:Static this:ConnectionDialog.UnwrapText}"/>
<Setter Property="ToolTip" Value="Turn off word wrap (Ctrl+W)"/>
</DataTrigger>
</Style.Triggers>
Expand Down
6 changes: 6 additions & 0 deletions Src/CsvLINQPadDriver/ConnectionDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ internal partial class ConnectionDialog
public static readonly RoutedUICommand PasteWithFolderAndItsSubfoldersCommand = new();
public static readonly RoutedUICommand WrapFilesTextCommand = new();

private static T IfWin10<T>(T ifTrue, T ifFalse) =>
Environment.OSVersion.Version.Major >= 10 ? ifTrue : ifFalse;

public static readonly string WrapText = IfWin10("⭹", "Wrap");
public static readonly string UnwrapText = IfWin10("⭲", "Unwrap");

public static readonly string WildcardsToolTip = $"Type one file/folder per line. Wildcards ? and * are supported; {FileExtensions.DefaultRecursiveMask} searches in folder and its sub-folders";

private bool _addFolderAndItsSubfoldersDialogOpened;
Expand Down
2 changes: 1 addition & 1 deletion Src/CsvLINQPadDriver/CsvDataContextDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#if NETCOREAPP
using System.Collections.Immutable;
#else
using CsvLINQPadDriver.Microsoft.Bcl;
using CsvLINQPadDriver.Bcl.Extensions;
#endif

namespace CsvLINQPadDriver
Expand Down
2 changes: 1 addition & 1 deletion Src/CsvLINQPadDriver/CsvLINQPadDriver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<Compile Remove="Microsoft.Bcl\**" />
<Compile Remove="Bcl\**" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Src/CsvLINQPadDriver/DataDisplay/CsvRowMemberProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#if NETCOREAPP
using System.Collections.Immutable;
#else
using CsvLINQPadDriver.Microsoft.Bcl;
using CsvLINQPadDriver.Bcl.Extensions;
#endif

namespace CsvLINQPadDriver.DataDisplay
Expand Down
2 changes: 1 addition & 1 deletion Src/CsvLINQPadDriver/DataModel/CsvDataModelGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#if NETCOREAPP
using System.Collections.Immutable;
#else
using CsvLINQPadDriver.Microsoft.Bcl;
using CsvLINQPadDriver.Bcl.Extensions;
#endif

namespace CsvLINQPadDriver.DataModel
Expand Down
7 changes: 3 additions & 4 deletions Src/CsvLINQPadDriver/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Project>
<PropertyGroup>
<Version>6.14.0</Version>
<PackageReleaseNotes>Added use record type option.
Generation string comparison can be used for comparing interned strings.</PackageReleaseNotes>
<Version>6.14.1</Version>
<PackageReleaseNotes>Bugfixes.</PackageReleaseNotes>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -40,7 +39,7 @@ Generation string comparison can be used for comparing interned strings.</Packag
</PackageReference>
<PackageReference Include="LINQPad.Reference" Version="1.1.0" />
<PackageReference Include="Microsoft-WindowsAPICodePack-Core" Version="1.1.4" />
<PackageReference Include="UnicodeCharsetDetector.Standard" Version="1.0.1" />
<PackageReference Include="UnicodeCharsetDetector.Standard" Version="1.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
31 changes: 31 additions & 0 deletions Src/CsvLINQPadDriver/Extensions/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;

namespace CsvLINQPadDriver.Extensions
{
internal static class EnumerableExtensions
{
public static IEnumerable<T> SkipExceptions<T>(this IEnumerable<T> source, ICollection<Exception>? exceptions = null)
{
using var enumerator = source.GetEnumerator();

while (true)
{
try
{
if (!enumerator.MoveNext())
{
break;
}
}
catch (Exception exception)
{
exceptions?.Add(exception);
continue;
}

yield return enumerator.Current;
}
}
}
}
46 changes: 12 additions & 34 deletions Src/CsvLINQPadDriver/Extensions/FileExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#if NETCOREAPP
using System.Collections.Immutable;
#else
using CsvLINQPadDriver.Microsoft.Bcl;
using CsvLINQPadDriver.Bcl.Extensions;
#endif

namespace CsvLINQPadDriver.Extensions
Expand Down Expand Up @@ -414,14 +414,17 @@ private static IEnumerable<string> EnumFiles(string path, ICollection<Exception>
baseDir = Path.GetDirectoryName(path) ?? string.Empty;
}

return !Directory.Exists(baseDir)
? Enumerable.Empty<string>()
: Directory
.EnumerateFiles(baseDir, fileOrMask,
Path.GetFileNameWithoutExtension(fileOrMask).Contains(RecursiveMaskMarker)
? SearchOption.AllDirectories
: SearchOption.TopDirectoryOnly)
.SafeWalk(exceptions);
return
#if NETCOREAPP
Directory
#else
exceptions
#endif
.EnumerateFiles(baseDir, fileOrMask,
Path.GetFileNameWithoutExtension(fileOrMask).Contains(RecursiveMaskMarker)
? SearchOption.AllDirectories
: SearchOption.TopDirectoryOnly)
.SkipExceptions(exceptions);
}
catch (Exception exception)
{
Expand All @@ -431,31 +434,6 @@ private static IEnumerable<string> EnumFiles(string path, ICollection<Exception>
}
}

private static IEnumerable<T> SafeWalk<T>(this IEnumerable<T> source, ICollection<Exception>? exceptions = null)
{
using var enumerator = source.GetEnumerator();

bool? hasCurrent;

do
{
try
{
hasCurrent = enumerator.MoveNext();
}
catch (Exception exception)
{
exceptions?.Add(exception);
hasCurrent = null;
}

if (hasCurrent is true)
{
yield return enumerator.Current;
}
} while (hasCurrent ?? true);
}

private static IEnumerable<string[]> CsvReadRows(
string fileName,
char? csvSeparator,
Expand Down
2 changes: 1 addition & 1 deletion Src/CsvLINQPadDriver/SchemaBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using System.IO;
using Microsoft.CSharp;

using CsvLINQPadDriver.Microsoft.Bcl;
using CsvLINQPadDriver.Bcl.Extensions;
#endif

namespace CsvLINQPadDriver
Expand Down
2 changes: 1 addition & 1 deletion Src/CsvLINQPadDriver/app.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<assemblyIdentity
name="CsvLINQPadDriver"
version="6.14.0.0"
version="6.14.1.0"
type="win32"
/>

Expand Down
9 changes: 3 additions & 6 deletions Src/LPRun/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ namespace LPRun
public static class Context
{
private static readonly string BaseDir = GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath)!;

private static readonly string LpRunDir = GetFullPath("LPRun");
private static readonly string LpRunExe = $"LPRun6{(Environment.Is64BitProcess ? string.Empty : "-x86")}.exe";

private static readonly string ExeDir = GetLpRunFullPath("Bin");
private static readonly string TemplatesDir = GetLpRunFullPath("Templates");
private static readonly string DataDir = GetLpRunFullPath("Data");

public static string FilesDir { get; } = GetLpRunFullPath("Files");
public static string Exe { get; } = Combine(ExeDir, GetLpRunExe());
public static string Exe { get; } = Combine(ExeDir, LpRunExe);

public static string GetExeFullPath(string path) =>
Combine(ExeDir, path);
Expand All @@ -36,10 +38,5 @@ public static string GetFullPath(string path) =>

private static string GetLpRunFullPath(string path) =>
Combine(LpRunDir, path);

private static string GetLpRunExe() =>
Environment.Is64BitProcess
? "LPRun6.exe"
: "LPRun6-x86.exe";
}
}
6 changes: 6 additions & 0 deletions Src/LPRun/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<PropertyGroup>
<Version>6.14.10</Version>
<PackageReleaseNotes>LPRun 6.14.10</PackageReleaseNotes>
</PropertyGroup>
</Project>
4 changes: 0 additions & 4 deletions Src/LPRun/LPRun.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
<Description>LINQPad driver LPRun unit/integration tests runner.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/i2van/CsvLINQPadDriver</RepositoryUrl>
<PackageReleaseNotes>LPRun 6.13.13 NuGet fixes.</PackageReleaseNotes>
<Copyright>Copyright © 2021 Ivan Ivon, LINQPad/LPRun by Joseph Albahari</Copyright>
<AssemblyVersion>6.13.14.0</AssemblyVersion>
<FileVersion>6.13.14.0</FileVersion>
<Version>6.13.14</Version>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
</PropertyGroup>

Expand Down
Binary file modified Src/LPRun/LPRun/Bin/LINQPad.Runtime.dll
Binary file not shown.
Binary file modified Src/LPRun/LPRun/Bin/LPRun6-x86.exe
Binary file not shown.
Binary file modified Src/LPRun/LPRun/Bin/LPRun6.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion Tests/CsvLINQPadDriverTest/CsvLINQPadDriverTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="LPRun" Version="6.13.14" />
<PackageReference Include="LPRun" Version="6.14.10" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="NUnit" Version="3.13.2" />
Expand Down

0 comments on commit fc8626d

Please sign in to comment.