Skip to content

Commit c105122

Browse files
committed
Release v4.11.2.0
CLI - Updating current directory via -l switch is disabled for all custom command scripts. - Added public extension methods - Reset dotnet-engine project template on the change of the target framework (set via `-self-rt`) - Added a small automation library `shell.cs` to the distribution - added `-scrumble` custom command - added `shell.cs` lib-script CSScriptLib - no changes
1 parent 10dad70 commit c105122

File tree

17 files changed

+365
-346
lines changed

17 files changed

+365
-346
lines changed

help.txt

Lines changed: 161 additions & 172 deletions
Large diffs are not rendered by default.

src/1.build-binaries.cmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ rd "out\Windows\console" /S /Q
110110
rem .\static_content contains Linux and Win specific files
111111
copy "out\static_content\global-usings.cs" "out\Windows\lib\global-usings.cs"
112112
copy "out\static_content\global-usings.cs" "out\Linux\lib\global-usings.cs"
113+
copy "out\static_content\lib\*" "out\Windows\lib\"
114+
copy "out\static_content\lib\*" "out\Linux\lib\"
113115

114116
rem goto:exit
115117
echo =====================

src/CSScriptLib/src/CSScriptLib/BuildServer.proxy.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Net;
55
using System.Net.Sockets;
66
using System.Text;
7+
using CSScripting;
78

89
namespace CSScriptLib
910
{
Lines changed: 121 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,127 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
3-
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
5-
<AssemblyName>CSScriptLib</AssemblyName>
6-
<LangVersion>latest</LangVersion>
7-
<PackageId>CS-Script</PackageId>
8-
<!--<NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>-->
9-
<!--<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>-->
10-
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
11-
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
12-
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
13-
<PublishRepositoryUrl>true</PublishRepositoryUrl>
14-
<IncludeSymbols>true</IncludeSymbols>
15-
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
16-
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
17-
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
18-
<Version>4.11.1.0</Version>
19-
<Authors>Oleg Shilo</Authors>
20-
<Description>CS-Script engine Class Library for .NET 5 (and higher)</Description>
21-
<Copyright>(C) 2018-2023 Oleg Shilo</Copyright>
22-
<PackageLicenseUrl></PackageLicenseUrl>
23-
<PackageProjectUrl>https://github.com/oleg-shilo/cs-script</PackageProjectUrl>
24-
<PackageIconUrl></PackageIconUrl>
25-
<RepositoryUrl>https://github.com/oleg-shilo/cs-script.git</RepositoryUrl>
26-
<RepositoryType>Git</RepositoryType>
27-
<PackageTags>C#, scripting, script, dynamic, .NET. .NET Core</PackageTags>
28-
<PackageReleaseNotes>
29-
---
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<AssemblyName>CSScriptLib</AssemblyName>
6+
<LangVersion>latest</LangVersion>
7+
<PackageId>CS-Script</PackageId>
8+
<!--<NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>-->
9+
<!--<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>-->
10+
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
11+
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
12+
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
13+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
14+
<IncludeSymbols>true</IncludeSymbols>
15+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
16+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
17+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
18+
<Version>4.11.2.0</Version>
19+
<Authors>Oleg Shilo</Authors>
20+
<Description>CS-Script engine Class Library for .NET 5 (and higher)</Description>
21+
<Copyright>(C) 2018-2023 Oleg Shilo</Copyright>
22+
<PackageLicenseUrl></PackageLicenseUrl>
23+
<PackageProjectUrl>https://github.com/oleg-shilo/cs-script</PackageProjectUrl>
24+
<PackageIconUrl></PackageIconUrl>
25+
<RepositoryUrl>https://github.com/oleg-shilo/cs-script.git</RepositoryUrl>
26+
<RepositoryType>Git</RepositoryType>
27+
<PackageTags>C#, scripting, script, dynamic, .NET. .NET Core</PackageTags>
28+
<PackageReleaseNotes>---
3029

31-
## Changes
30+
## Changes
3231

33-
### CLI
34-
- Added `-self-rt` custom command for setting the script engine runtime version
32+
### CLI
33+
- Updating current directory via -l switch is disabled for all custom command scripts.
34+
- Added public extension methods
35+
- Reset dotnet-engine project template on the change of the target framework (set via `-self-rt`)
36+
- Added a small automation library `shell.cs` to the distribution
37+
- added `-scrumble` custom command
38+
- added `shell.cs` lib-script
3539

36-
### CSScriptLib
37-
- no changes
38-
</PackageReleaseNotes>
39-
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
40-
<AssemblyVersion>4.11.1.0</AssemblyVersion>
41-
<FileVersion>4.11.1.0</FileVersion>
42-
<PackageVersion>4.11.1.0</PackageVersion>
43-
<PackageLicenseExpression>MIT</PackageLicenseExpression>
44-
<PackageIcon>css_logo.png</PackageIcon>
45-
<SignAssembly>True</SignAssembly>
46-
<AssemblyOriginatorKeyFile>sgKey.snk</AssemblyOriginatorKeyFile>
47-
</PropertyGroup>
48-
<ItemGroup>
49-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
50-
</ItemGroup>
51-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
52-
<DocumentationFile>CSScriptLib.xml</DocumentationFile>
53-
<PlatformTarget>AnyCPU</PlatformTarget>
54-
<DefineConstants>TRACE;class_lib</DefineConstants>
55-
</PropertyGroup>
56-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
57-
<DocumentationFile>CSScriptLib.xml</DocumentationFile>
58-
<DefineConstants>TRACE;class_lib</DefineConstants>
59-
</PropertyGroup>
60-
<ItemGroup>
61-
<Compile Remove="CSScriptLib.Eval.CodeDom.cs" />
62-
<Compile Remove="output\aggregate.cs" />
63-
<Compile Remove="output\Test.cs" />
64-
<Compile Remove="sample.cs" />
65-
<Compile Remove="samples.cs" />
66-
</ItemGroup>
67-
<ItemGroup>
68-
<None Remove="nuget-samples.cmd" />
69-
</ItemGroup>
70-
<ItemGroup>
71-
<Compile Include="..\..\..\cscs\CodeDom\CompilerResults.cs" Link="CodeDom\CompilerResults.cs" />
72-
<Compile Include="..\..\..\cscs\CodeDom\CompilerError.cs" Link="CodeDom\CompilerError.cs" />
73-
<Compile Include="..\..\..\cscs\fileparser.cs" Link="fileparser.cs" />
74-
<Compile Include="..\..\..\cscs\Project.cs" Link="Project.cs" />
75-
<Compile Include="..\..\..\cscs\ScriptParser.cs" Link="ScriptParser.cs" />
76-
<Compile Include="..\..\..\cscs\ScriptParsingResult.cs" Link="ScriptParsingResult.cs" />
77-
<Compile Include="..\..\..\cscs\Utils\CoreExtensions.cs" Link="Utils\CoreExtensions.cs" />
78-
<Compile Include="..\..\..\cscs\Utils\CurrentDirGuard.cs" Link="Utils\CurrentDirGuard.cs" />
79-
<Compile Include="..\..\..\cscs\Utils\LinqExtensions.cs" Link="Utils\LinqExtensions.cs" />
80-
<Compile Include="..\..\..\cscs\Utils\PathExtensions.cs" Link="Utils\PathExtensions.cs" />
81-
<Compile Include="..\..\..\cscs\Utils\Globals.cs" Link="Utils\Globals.cs" />
82-
<Compile Include="..\..\..\cscs\Utils\Profiler.cs" Link="Profiler.cs" />
83-
<Compile Include="..\..\..\cscs\Utils\ReflectionExtensions.cs" Link="Utils\ReflectionExtensions.cs" />
84-
<Compile Include="..\..\..\cscs\Utils\Runtime.cs" Link="Utils\Runtime.cs" />
85-
<Compile Include="..\..\..\cscs\Utils\SimpleAsmProbing.cs" Link="SimpleAsmProbing.cs" />
86-
<Compile Include="..\..\..\cscs\Utils\SocketExtensions.cs" Link="SocketExtensions.cs" />
87-
<Compile Include="..\..\..\cscs\Utils\StringExtensions.cs" Link="Utils\StringExtensions.cs" />
88-
<Compile Include="..\..\..\cscs\Utils\WildCardExtensions.cs" Link="Utils\WildCardExtensions.cs" />
89-
</ItemGroup>
90-
<ItemGroup>
91-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.14.0" />
92-
<PackageReference Include="Microsoft.CodeAnalysis.Scripting.Common" Version="4.14.0" />
93-
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
94-
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="9.0.7" />
95-
<PackageReference Include="System.Text.Json" Version="9.0.7" />
96-
</ItemGroup>
97-
<ItemGroup>
98-
<None Include="..\..\..\logo\css_logo.png">
99-
<Pack>True</Pack>
100-
<PackagePath></PackagePath>
101-
</None>
102-
<None Include="samples.cs" />
103-
</ItemGroup>
104-
<ItemGroup>
105-
<Folder Include="CodeDom\" />
106-
</ItemGroup>
107-
<ItemGroup>
108-
<Compile Update="Properties\Resources.Designer.cs">
109-
<DependentUpon>Resources.resx</DependentUpon>
110-
<DesignTime>True</DesignTime>
111-
<AutoGen>True</AutoGen>
112-
</Compile>
113-
</ItemGroup>
114-
<ItemGroup>
115-
<EmbeddedResource Update="Properties\Resources.resx">
116-
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
117-
<Generator>ResXFileCodeGenerator</Generator>
118-
<CustomToolNamespace>CSScripting</CustomToolNamespace>
119-
</EmbeddedResource>
120-
</ItemGroup>
121-
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
122-
<Exec Command="IF exist &quot;$(ProjectDir)out&quot; ( echo . ) ELSE ( md &quot;$(ProjectDir)out&quot;)&#xD;&#xA;&#xD;&#xA;copy &quot;$(TargetDir)$(TargetFileName)&quot; &quot;$(ProjectDir)output\$(TargetFileName)&quot;&#xD;&#xA;copy &quot;$(TargetDir)$(ProjectName).xml&quot; &quot;$(ProjectDir)output\$(ProjectName).xml&quot;&#xD;&#xA;rem copy &quot;$(ProjectDir)..\..\src\CSScriptLib.Client\Test.cs&quot; &quot;$(ProjectDir)output\Test.cs&quot;&#xD;&#xA;rem copy &quot;$(ProjectDir)..\..\src\CSScriptLib.Client\Test.cs&quot; &quot;$(ProjectDir)bin\$(ConfigurationName)\Test.cs&quot;&#xD;&#xA;&#xD;&#xA;" />
123-
</Target>
40+
### CSScriptLib
41+
- no changes</PackageReleaseNotes>
42+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
43+
<AssemblyVersion>4.11.2.0</AssemblyVersion>
44+
<FileVersion>4.11.2.0</FileVersion>
45+
<PackageVersion>4.11.2.0</PackageVersion>
46+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
47+
<PackageIcon>css_logo.png</PackageIcon>
48+
<SignAssembly>True</SignAssembly>
49+
<AssemblyOriginatorKeyFile>sgKey.snk</AssemblyOriginatorKeyFile>
50+
</PropertyGroup>
51+
<ItemGroup>
52+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
53+
</ItemGroup>
54+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
55+
<DocumentationFile>CSScriptLib.xml</DocumentationFile>
56+
<PlatformTarget>AnyCPU</PlatformTarget>
57+
<DefineConstants>TRACE;class_lib</DefineConstants>
58+
</PropertyGroup>
59+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
60+
<DocumentationFile>CSScriptLib.xml</DocumentationFile>
61+
<DefineConstants>TRACE;class_lib</DefineConstants>
62+
</PropertyGroup>
63+
<ItemGroup>
64+
<Compile Remove="CSScriptLib.Eval.CodeDom.cs" />
65+
<Compile Remove="output\aggregate.cs" />
66+
<Compile Remove="output\Test.cs" />
67+
<Compile Remove="sample.cs" />
68+
<Compile Remove="samples.cs" />
69+
</ItemGroup>
70+
<ItemGroup>
71+
<None Remove="nuget-samples.cmd" />
72+
</ItemGroup>
73+
<ItemGroup>
74+
<Compile Include="..\..\..\cscs\CodeDom\CompilerResults.cs" Link="CodeDom\CompilerResults.cs" />
75+
<Compile Include="..\..\..\cscs\CodeDom\CompilerError.cs" Link="CodeDom\CompilerError.cs" />
76+
<Compile Include="..\..\..\cscs\fileparser.cs" Link="fileparser.cs" />
77+
<Compile Include="..\..\..\cscs\Project.cs" Link="Project.cs" />
78+
<Compile Include="..\..\..\cscs\ScriptParser.cs" Link="ScriptParser.cs" />
79+
<Compile Include="..\..\..\cscs\ScriptParsingResult.cs" Link="ScriptParsingResult.cs" />
80+
<Compile Include="..\..\..\cscs\Utils\CoreExtensions.cs" Link="Utils\CoreExtensions.cs" />
81+
<Compile Include="..\..\..\cscs\Utils\CurrentDirGuard.cs" Link="Utils\CurrentDirGuard.cs" />
82+
<Compile Include="..\..\..\cscs\Utils\LinqExtensions.cs" Link="Utils\LinqExtensions.cs" />
83+
<Compile Include="..\..\..\cscs\Utils\PathExtensions.cs" Link="Utils\PathExtensions.cs" />
84+
<Compile Include="..\..\..\cscs\Utils\Globals.cs" Link="Utils\Globals.cs" />
85+
<Compile Include="..\..\..\cscs\Utils\Profiler.cs" Link="Profiler.cs" />
86+
<Compile Include="..\..\..\cscs\Utils\ReflectionExtensions.cs" Link="Utils\ReflectionExtensions.cs" />
87+
<Compile Include="..\..\..\cscs\Utils\Runtime.cs" Link="Utils\Runtime.cs" />
88+
<Compile Include="..\..\..\cscs\Utils\SimpleAsmProbing.cs" Link="SimpleAsmProbing.cs" />
89+
<Compile Include="..\..\..\cscs\Utils\SocketExtensions.cs" Link="SocketExtensions.cs" />
90+
<Compile Include="..\..\..\cscs\Utils\StringExtensions.cs" Link="Utils\StringExtensions.cs" />
91+
<Compile Include="..\..\..\cscs\Utils\WildCardExtensions.cs" Link="Utils\WildCardExtensions.cs" />
92+
</ItemGroup>
93+
<ItemGroup>
94+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.14.0" />
95+
<PackageReference Include="Microsoft.CodeAnalysis.Scripting.Common" Version="4.14.0" />
96+
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
97+
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="9.0.7" />
98+
<PackageReference Include="System.Text.Json" Version="9.0.7" />
99+
</ItemGroup>
100+
<ItemGroup>
101+
<None Include="..\..\..\logo\css_logo.png">
102+
<Pack>True</Pack>
103+
<PackagePath></PackagePath>
104+
</None>
105+
<None Include="samples.cs" />
106+
</ItemGroup>
107+
<ItemGroup>
108+
<Folder Include="CodeDom\" />
109+
</ItemGroup>
110+
<ItemGroup>
111+
<Compile Update="Properties\Resources.Designer.cs">
112+
<DependentUpon>Resources.resx</DependentUpon>
113+
<DesignTime>True</DesignTime>
114+
<AutoGen>True</AutoGen>
115+
</Compile>
116+
</ItemGroup>
117+
<ItemGroup>
118+
<EmbeddedResource Update="Properties\Resources.resx">
119+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
120+
<Generator>ResXFileCodeGenerator</Generator>
121+
<CustomToolNamespace>CSScripting</CustomToolNamespace>
122+
</EmbeddedResource>
123+
</ItemGroup>
124+
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
125+
<Exec Command="IF exist &quot;$(ProjectDir)out&quot; ( echo . ) ELSE ( md &quot;$(ProjectDir)out&quot;)&#xD;&#xA;&#xD;&#xA;copy &quot;$(TargetDir)$(TargetFileName)&quot; &quot;$(ProjectDir)output\$(TargetFileName)&quot;&#xD;&#xA;copy &quot;$(TargetDir)$(ProjectName).xml&quot; &quot;$(ProjectDir)output\$(ProjectName).xml&quot;&#xD;&#xA;rem copy &quot;$(ProjectDir)..\..\src\CSScriptLib.Client\Test.cs&quot; &quot;$(ProjectDir)output\Test.cs&quot;&#xD;&#xA;rem copy &quot;$(ProjectDir)..\..\src\CSScriptLib.Client\Test.cs&quot; &quot;$(ProjectDir)bin\$(ConfigurationName)\Test.cs&quot;&#xD;&#xA;&#xD;&#xA;" />
126+
</Target>
124127
</Project>

src/Tests.cscs/cli.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public cscs_cli(ITestOutputHelper output)
5858
var config = "Release";
5959
#endif
6060
cscs_exe = Environment.GetEnvironmentVariable("css_test_asm") ?? $@"..\..\..\..\..\cscs\bin\{config}\net{Environment.Version.Major}.0\cscs.dll".GetFullPath();
61+
6162
var cmd_dir = cscs_exe.ChangeFileName("-self");
6263

6364
if (cmd_dir.DirExists())
@@ -76,7 +77,9 @@ public cscs_cli(ITestOutputHelper output)
7677
string cscs_run(string args, string dir = null)
7778
{
7879
// print method input
80+
// Console.WriteLine($"currdir: {Environment.CurrentDirectory}");
7981
// Console.WriteLine($"{cscs_exe} {args}");
82+
// Console.WriteLine($"==================");
8083

8184
var output = "dotnet".Run($"\"{cscs_exe}\" {args}", dir).output.Trim();
8285

@@ -328,17 +331,22 @@ public void distro_commands()
328331
var is_win = (Environment.OSVersion.Platform == PlatformID.Win32NT);
329332

330333
var commands = Directory.GetFiles(static_content, "-run.cs", SearchOption.AllDirectories);
334+
331335
foreach (var file in commands)
332336
{
333337
var cmd = file.GetDirName().GetFileName();
334338

335339
if (cmd == "-exe") continue;
336340

337341
var probing_dir = $"-dir:{static_content}";
338-
var extra_arg = cmd.IsOneOf("-wdbg", "-web", "-test", "-exe", "-update", "-alias") ? "-?" : "";
342+
// var extra_arg = cmd.IsOneOf("-wdbg", "-web", "-test", "-exe", "-update", "-scramble", "-alias", "-rt") ? "-?" : "";
343+
var extra_arg = "-?";
339344

340345
(var output, var exitCode) = cscs_runx($"{file} {extra_arg}");
341346

347+
// Console.WriteLine($"{cmd}: {file}");
348+
// Console.WriteLine($"{exitCode}: {output}");
349+
342350
var context = $"{file}\n{output.TakeMax(100)}";
343351

344352
Assert.True(0 == exitCode, $"Failed to build/execute: \n{context}");

src/chocolatey/cs-script.nuspec

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
33
<metadata>
44
<id>cs-script</id>
5-
<version>4.11.1.0</version>
5+
<version>4.11.2.0</version>
66
<title>CS-Script</title>
77
<authors>Oleg Shilo</authors>
88
<owners>Oleg Shilo</owners>
@@ -29,7 +29,12 @@
2929
## Changes
3030

3131
### CLI
32-
- Added `-self-rt` custom command for setting the script engine runtime version
32+
- Updating current directory via -l switch is disabled for all custom command scripts.
33+
- Added public extension methods
34+
- Reset dotnet-engine project template on the change of the target framework (set via `-self-rt`)
35+
- Added a small automation library `shell.cs` to the distribution
36+
- added `-scrumble` custom command
37+
- added `shell.cs` lib-script
3338

3439
### CSScriptLib
3540
- no changes</releaseNotes>

src/cscs/Utils/CoreExtensions.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,6 @@ internal static string[] RemovePathDuplicates(this string[] list)
225225

226226
internal static string[] SharedAssembliesNames => Directory.GetFiles(sdk_root, "*.dll").Select(Path.GetFileName).ToArray();
227227

228-
/// <summary>
229-
/// Converts to bool.
230-
/// </summary>
231-
/// <param name="text">The text.</param>
232228
/// <summary>
233229
/// Removes the assembly extension.
234230
/// </summary>

src/cscs/Utils/SocketExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Net;
33
using System.Net.Sockets;
44
using System.Text;
5+
using CSScripting;
56

67
static class SharedExtensions // will need to be refactored into a truly shared set of extension methods
78
{

src/cscs/Utils/StringExtensions.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using System.Text;
45
using csscript;
56

67
namespace CSScripting
@@ -158,6 +159,7 @@ public static bool ToBool(this string text)
158159
public static double? ToDouble(this string text)
159160
=> double.TryParse(text, out var result) ? result : null;
160161

162+
//needed to have reliable HASH as x64 and x32 have different algorithms; This leads to the inability of script clients calculate cache directory correctly
161163
/// <summary>
162164
/// The custom implementation of the <see cref="string.GetHashCode"/> method.
163165
/// </summary>
@@ -190,7 +192,21 @@ public static int GetHashCodeEx(this string text)
190192
#endif
191193
}
192194

193-
//needed to have reliable HASH as x64 and x32 have different algorithms; This leads to the inability of script clients calculate cache directory correctly
195+
/// <summary>
196+
/// Gets the bytes.
197+
/// </summary>
198+
/// <param name="data">The data.</param>
199+
/// <param name="encoding">The encoding.</param>
200+
/// <returns></returns>
201+
public static byte[] GetBytes(this string data, Encoding encoding = null) => (encoding ?? Encoding.UTF8).GetBytes(data);
202+
203+
/// <summary>
204+
/// Gets the string.
205+
/// </summary>
206+
/// <param name="data">The data.</param>
207+
/// <param name="encoding">The encoding.</param>
208+
/// <returns></returns>
209+
public static string GetString(this byte[] data, Encoding encoding = null) => (encoding ?? Encoding.UTF8).GetString(data);
194210
}
195211
}
196212

0 commit comments

Comments
 (0)