Skip to content

Commit

Permalink
Added .NET 6/8.
Browse files Browse the repository at this point in the history
Reintroduced assembly signing.#
  • Loading branch information
AndrewRissing committed Dec 2, 2023
1 parent 74fda06 commit 3bccab5
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ Backup*/
UpgradeLog*.XML

.vs/
GenericParsing/GenericParsing.pfx
GenericParsing/GenericParsing.snk
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\SolutionVersionInfo.cs">
<Link>Properties\SolutionVersionInfo.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PerformanceTests.cs">
<SubType>Code</SubType>
Expand Down
10 changes: 5 additions & 5 deletions GenericParsing.UnitTests/GenericParsing.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net4.8</TargetFramework>
<TargetFrameworks>net481;net6.0;net8.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
Expand Down Expand Up @@ -315,13 +315,13 @@
<EmbeddedResource Include="TestData\XmlTest.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
3 changes: 0 additions & 3 deletions GenericParsing.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{936F8079-8AE8-4F7A-921C-9E44920F4B9E}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
GenericParsing.vsmdi = GenericParsing.vsmdi
LICENSE.md = LICENSE.md
localtestrun.testrunconfig = localtestrun.testrunconfig
README.md = README.md
SolutionVersionInfo.cs = SolutionVersionInfo.cs
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GenericParsing.PerformanceTests", "GenericParsing.PerformanceTests\GenericParsing.PerformanceTests.csproj", "{28A4801F-B624-4AED-9765-B172203EB188}"
Expand Down
24 changes: 10 additions & 14 deletions GenericParsing/GenericParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ private enum RowType
private const string XML_ESCAPE_CHARACTER = "EscapeCharacter";
private const string XML_COMMENT_CHARACTER = "CommentCharacter";

private const string XML_SAFE_STRING_DELIMITER = ",";

#endregion XmlConfig Constants

#endregion Constants
Expand Down Expand Up @@ -290,13 +288,13 @@ public int[] ColumnWidths
else
{
if (this.m_iaColumnWidths.Length < 1)
throw new ArgumentOutOfRangeException("value", "ColumnWidths cannot be an empty array.");
throw new ArgumentOutOfRangeException(nameof(ColumnWidths), "ColumnWidths cannot be an empty array.");

// Make sure all of the ColumnWidths are valid.
for (int intColumnIndex = 0; intColumnIndex < this.m_iaColumnWidths.Length; ++intColumnIndex)
{
if (this.m_iaColumnWidths[intColumnIndex] < 1)
throw new ArgumentOutOfRangeException("value", "ColumnWidths cannot contain a number less than one.");
throw new ArgumentOutOfRangeException(nameof(ColumnWidths), "ColumnWidths cannot contain a number less than one.");
}

this.m_textFieldType = FieldType.FixedWidth;
Expand Down Expand Up @@ -338,7 +336,7 @@ public int MaxBufferSize
if (value > 0)
this.m_intMaxBufferSize = value;
else
throw new ArgumentOutOfRangeException("value", value, "The MaxBufferSize must be greater than 0.");
throw new ArgumentOutOfRangeException(nameof(MaxBufferSize), value, "The MaxBufferSize must be greater than 0.");
}
}
/// <summary>
Expand Down Expand Up @@ -1012,11 +1010,11 @@ public void SetDataSource(string strFileName, Encoding encoding)
if (this.m_ParserState == ParserState.Parsing)
throw new InvalidOperationException("Parsing has already begun, close the existing parse first.");
if (strFileName == null)
throw new ArgumentNullException("strFileName", "The filename cannot be a null value.");
throw new ArgumentNullException(nameof(strFileName), "The filename cannot be a null value.");
if (!File.Exists(strFileName))
throw new ArgumentException(string.Format("File, {0}, does not exist.", strFileName), "strFileName");
throw new ArgumentException(string.Format("File, {0}, does not exist.", strFileName), nameof(strFileName));
if (encoding == null)
throw new ArgumentNullException("encoding", "The encoding cannot be a null value.");
throw new ArgumentNullException(nameof(encoding), "The encoding cannot be a null value.");

// Clean up the existing text reader if it exists.
if (this.m_txtReader != null)
Expand Down Expand Up @@ -1047,15 +1045,13 @@ public void SetDataSource(TextReader txtReader)
{
if (this.m_ParserState == ParserState.Parsing)
throw new InvalidOperationException("Parsing has already begun, close the existing parse first.");
if (txtReader == null)
throw new ArgumentNullException("txtReader", "The text reader cannot be a null value.");

// Clean up the existing text reader if it exists.
if (this.m_txtReader != null)
this.m_txtReader.Dispose();

this.m_ParserState = ParserState.Ready;
this.m_txtReader = txtReader;
this.m_txtReader = txtReader ?? throw new ArgumentNullException(nameof(txtReader), "The text reader cannot be a null value.");
}

/// <summary>
Expand Down Expand Up @@ -1830,9 +1826,9 @@ public void Dispose()
/// </summary>
protected virtual void OnDisposed()
{
if (this.Disposed != null)
this.Disposed(this, EventArgs.Empty);
this.Disposed?.Invoke(this, EventArgs.Empty);
}

/// <summary>
/// Releases the all unmanaged resources used by this instance and optionally releases the managed resources.
/// </summary>
Expand Down Expand Up @@ -1908,7 +1904,7 @@ protected virtual void Dispose(bool blnDisposing)

#endregion Parsing Variables

private object m_objLock;
private readonly object m_objLock;
private bool m_blnDisposed;

/// <summary>
Expand Down
16 changes: 10 additions & 6 deletions GenericParsing/GenericParsing.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.3.0</Version>
<Version>1.5.0</Version>
<Authors>Andrew Rissing</Authors>
<Company>N/A</Company>
<Owners>AndrewRissing</Owners>
Expand All @@ -14,11 +14,11 @@
<PackageProjectUrl>https://github.com/AndrewRissing/GenericParsing</PackageProjectUrl>
<PackageIconUrl></PackageIconUrl>
<PackageTags>GenericParsing Parsing CSV TSV Delimited</PackageTags>
<AssemblyVersion>1.3.0.0</AssemblyVersion>
<FileVersion>1.3.0.0</FileVersion>
<RepositoryUrl>https://github.com/AndrewRissing/GenericParsing</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<PackageReleaseNotes Condition="'$(Version)' == '1.3.0'">- Added ColumnNameComparisonMode (jonataspc).</PackageReleaseNotes>
<PackageReleaseNotes Condition="'$(Version)' == '1.5.0'">- Added .NET 6, .NET 8 compilations.
- Reintroduced signing the assembly.</PackageReleaseNotes>
<PackageReleaseNotes Condition="'$(Version)' == '1.3.0'">- Added ColumnNameComparisonMode (jonataspc).</PackageReleaseNotes>
<PackageReleaseNotes Condition="'$(Version)' == '1.2.2'">- Request only read access when opening a file.
- Updated the license to MIT.</PackageReleaseNotes>
<PackageReleaseNotes Condition="'$(Version)' == '1.2.1'">- Added new target frameworks (.NET 4.5.2, .NET 4.6.1).
Expand All @@ -28,6 +28,10 @@
- Signed the GenericParsing assembly.</PackageReleaseNotes>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>GenericParsing.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<None Include="GenericParsing.shfbproj" />
</ItemGroup>
Expand All @@ -36,4 +40,4 @@
<SubType>Code</SubType>
</Compile>
</ItemGroup>
</Project>
</Project>
28 changes: 20 additions & 8 deletions GenericParsing/ParsingException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,26 @@
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do so,
// of the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

using System;

#if !(NET6_0_OR_GREATER)
using System.Runtime.Serialization;
using System.Security.Permissions;
#endif

namespace GenericParsing
{
Expand All @@ -31,12 +34,14 @@ namespace GenericParsing
[Serializable]
public class ParsingException : Exception
{
#if !(NET6_0_OR_GREATER)
#region Constants

private const string SERIALIZATION_COLUMN_NUMBER = "ColumnNumber";
private const string SERIALIZATION_FILE_ROW_NUMBER = "FileRowNumber";

#endregion Constants
#endif

#region Constructors

Expand All @@ -47,6 +52,7 @@ public ParsingException() : base()
{
/* Intentionally left blank */
}

/// <summary>
/// Creates a new <see cref="ParsingException"/> containing a message and the
/// file line number that the error occured.
Expand All @@ -62,6 +68,8 @@ public ParsingException(string strMessage, int intFileRowNumber, int intColumnNu
this.m_intFileRowNumber = intFileRowNumber;
this.m_intColumnNumber = intColumnNumber;
}

#if !(NET6_0_OR_GREATER)
/// <summary>
/// Creates a new <see cref="ParsingException"/> with seralized data.
/// </summary>
Expand All @@ -79,6 +87,7 @@ protected ParsingException(SerializationInfo sInfo, StreamingContext sContext)
this.m_intFileRowNumber = sInfo.GetInt32(SERIALIZATION_FILE_ROW_NUMBER);
this.m_intColumnNumber = sInfo.GetInt32(SERIALIZATION_COLUMN_NUMBER);
}
#endif

#endregion Constructors

Expand All @@ -94,6 +103,7 @@ public int FileRowNumber
return this.m_intFileRowNumber;
}
}

/// <summary>
/// The column number in the file that the exception was thrown at.
/// </summary>
Expand All @@ -109,11 +119,12 @@ public int ColumnNumber

#region Private Members

private int m_intFileRowNumber;
private int m_intColumnNumber;
private readonly int m_intFileRowNumber;
private readonly int m_intColumnNumber;

#endregion Private Members

#if !(NET6_0_OR_GREATER)
#region Overridden Methods

/// <summary>
Expand All @@ -138,5 +149,6 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
}

#endregion Overridden Methods
#endif
}
}
}
37 changes: 0 additions & 37 deletions localtestrun.testrunconfig

This file was deleted.

0 comments on commit 3bccab5

Please sign in to comment.