Update to .NET 8 and VSCode build

This commit is contained in:
2024-05-20 11:13:06 -04:00
parent 9b8ae7d33b
commit 9cb24db93f
8 changed files with 52848 additions and 52881 deletions

0
LDIFTools.sln Executable file → Normal file
View File

9
LDIFTools/LDIFTools.csproj Executable file → Normal file
View File

@@ -1,15 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<DebugType>embedded</DebugType>
</PropertyGroup>
<ItemGroup>
<None Update="input.ldif">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

49
LDIFTools/Program.cs Executable file → Normal file
View File

@@ -1,5 +1,4 @@
using System.Net.NetworkInformation;
using System.Text;
using System.Text;
namespace LDIFTools
{
@@ -8,16 +7,16 @@ namespace LDIFTools
static string? InputFilename = null;
static string? OutputFilename = null;
static List<string> FileStart = new();
static SortedList<string, List<string>> SortedDNs = new();
static List<List<string>> NotSortedDNs = new();
static readonly List<string> FileStart = [];
static readonly SortedList<string, List<string>> SortedDNs = [];
static readonly List<List<string>> NotSortedDNs = [];
static bool SortDNs = false;
static bool RemoveComments = false;
static List<string> KeepStrings = new();
static List<string> RemoveStrings = new();
static readonly List<string> KeepStrings = [];
static readonly List<string> RemoveStrings = [];
static bool UseLongLines = false;
static List<string> AttrsToRemove = new();
static string DefaultAttrsToRemove = "showInAdvancedViewOnly,objectGUID,instanceType,dsCorePropagationData,distinguishedName,whenCreated,whenChanged,uSNCreated,uSNChanged,name,objectCategory";
static readonly List<string> AttrsToRemove = [];
static readonly string DefaultAttrsToRemove = "showInAdvancedViewOnly,objectGUID,instanceType,dsCorePropagationData,distinguishedName,whenCreated,whenChanged,uSNCreated,uSNChanged,name,objectCategory";
static bool SortVISConfigItems = false;
static bool UppercaseVISConfigItems = false;
@@ -76,7 +75,7 @@ namespace LDIFTools
ConsoleKeyInfo key = Console.ReadKey();
Console.WriteLine("\n");
if (key.KeyChar.ToString().ToLower() != "y")
if (!key.KeyChar.ToString().Equals("y", StringComparison.CurrentCultureIgnoreCase))
{
Console.WriteLine("No changes made");
return 0;
@@ -280,12 +279,12 @@ namespace LDIFTools
static void ReadInputFile(string inputFilename)
{
bool startOfFile = true;
List<string> currentBlock = new();
List<string> currentBlock = [];
string currentDN = "";
foreach (string line in File.ReadLines(inputFilename))
{
if (line.ToLower().StartsWith("dn:") && line.Trim().Length > 4)
if (line.StartsWith("dn:", StringComparison.InvariantCultureIgnoreCase) && line.Trim().Length > 4)
{
//We have a new dn block to read
@@ -303,10 +302,10 @@ namespace LDIFTools
//Start building a new block of lines
currentDN = ReverseDN(line.Trim().Replace("dn:", "").Trim().ToLower());
currentBlock = new()
{
currentBlock =
[
line
};
];
}
else if (startOfFile)
{
@@ -314,9 +313,9 @@ namespace LDIFTools
}
else
{
if (!(RemoveComments && line.Trim().StartsWith("#")))
if (!(RemoveComments && line.Trim().StartsWith('#')))
{
if (UseLongLines && line.StartsWith(" "))
if (UseLongLines && line.StartsWith(' '))
{
//append line (without starting space) to last line read from file
currentBlock[^1] += line[1..];
@@ -339,13 +338,13 @@ namespace LDIFTools
static List<string> FilterAttrs(List<string> dnBlock)
{
List<string> result = new();
List<string> result = [];
foreach (string line in dnBlock)
{
bool save = true;
foreach (string attr in AttrsToRemove)
{
if (line.ToLower().StartsWith(attr.ToLower() + ":"))
if (line.StartsWith(attr + ":", StringComparison.InvariantCultureIgnoreCase))
{
save = false;
break;
@@ -361,8 +360,8 @@ namespace LDIFTools
static List<string> CleanupVISConfigItems(List<string> dnBlock)
{
List<string> result = new();
SortedList<string, string> configItems = new();
List<string> result = [];
SortedList<string, string> configItems = [];
int startsAt = -1;
if (!SortVISConfigItems) return dnBlock;
@@ -370,13 +369,13 @@ namespace LDIFTools
int counter = 0;
foreach (string line in dnBlock)
{
if (line.ToLower().StartsWith("vis-configurationitem:"))
if (line.StartsWith("vis-configurationitem:", StringComparison.InvariantCultureIgnoreCase))
{
if (startsAt == -1) startsAt = counter;
string lineToClean;
bool base64 = false;
if (line.ToLower().StartsWith("vis-configurationitem::"))
if (line.StartsWith("vis-configurationitem::", StringComparison.InvariantCultureIgnoreCase))
{
//Base64 encoded attribute
base64 = true;
@@ -436,7 +435,7 @@ namespace LDIFTools
{
foreach (string keepString in KeepStrings)
{
if (dnLine.ToLower().Contains(keepString.ToLower()))
if (dnLine.Contains(keepString, StringComparison.InvariantCultureIgnoreCase))
{
keep = true;
break;
@@ -452,7 +451,7 @@ namespace LDIFTools
{
foreach (string removeString in RemoveStrings)
{
if (dnLine.ToLower().Contains(removeString.ToLower()))
if (dnLine.Contains(removeString, StringComparison.InvariantCultureIgnoreCase))
{
remove = true;
break;

View File

@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net7.0\publish\osx-arm64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net7.0</TargetFramework>
<RuntimeIdentifier>osx-arm64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<PublishTrimmed>true</PublishTrimmed>
</PropertyGroup>
</Project>

View File

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net7.0\publish\win-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net7.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>true</PublishReadyToRun>
<PublishTrimmed>true</PublishTrimmed>
</PropertyGroup>
</Project>

0
LDIFTools/input.ldif Executable file → Normal file
View File

2
publish.cmd Executable file
View File

@@ -0,0 +1,2 @@
dotnet publish --configuration Release --runtime osx-x64
dotnet publish --configuration Release --runtime win-x64