Skip to content

Commit

Permalink
Standardized repository.
Browse files Browse the repository at this point in the history
  • Loading branch information
tacosontitan committed Mar 12, 2024
1 parent 2933c63 commit d13fedd
Show file tree
Hide file tree
Showing 16 changed files with 335 additions and 310 deletions.
277 changes: 135 additions & 142 deletions .editorconfig

Large diffs are not rendered by default.

60 changes: 57 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,59 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>

<PropertyGroup Label="General Project Details">
<TargetFrameworks>
net4.8;
net6.0;
net7.0;
net8.0;
</TargetFrameworks>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<ImplicitUsings>true</ImplicitUsings>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>

<Title>$(AssemblyName)</Title>
<Version>$(AssemblyVersion)</Version>
<FileVersion>$(AssemblyVersion)</FileVersion>
<PackageVersion>$(AssemblyVersion)</PackageVersion>
</PropertyGroup>
</Project>

<PropertyGroup Label="Package Details">
<Description>A lightweight, provider agnostic, serialization proxy designed to simplify serialization definitions.</Description>
<PackageTags>provider;agnostic;serialization;proxy;json;xml;yaml;binary;toml;cbor</PackageTags>

<Authors>tacosontitan</Authors>
<Copyright>Copyright © 2023 tacosontitan and contibutors</Copyright>
<PackageProjectUrl>https://github.com/tacosontitan/Pasper</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageReleaseNotesFile>resources/docs/RELEASE_NOTES.md</PackageReleaseNotesFile>

<IncludeSymbols>True</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>

<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/tacosontitan/Pasper</RepositoryUrl>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\LICENSE">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
<Link>.resources\LICENSE</Link>
</None>
<None Include="..\..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
<Link>.resources\docs\README.md</Link>
</None>
<None Include="..\..\resources\docs\RELEASE_NOTES.md">
<Pack>False</Pack>
<Link>.resources\docs\RELEASE_NOTES.md</Link>
</None>
</ItemGroup>

</Project>
Empty file added resources/docs/RELEASE_NOTES.md
Empty file.
8 changes: 5 additions & 3 deletions src/Pasper.Json/Pasper.Json.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Pasper\Pasper.csproj" />
</ItemGroup>

</Project>
8 changes: 5 additions & 3 deletions src/Pasper.Toml/Pasper.Toml.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Pasper\Pasper.csproj" />
</ItemGroup>

</Project>
8 changes: 5 additions & 3 deletions src/Pasper.Xml/Pasper.Xml.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Pasper\Pasper.csproj" />
</ItemGroup>

</Project>
8 changes: 5 additions & 3 deletions src/Pasper.Yaml/Pasper.Yaml.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Pasper\Pasper.csproj" />
</ItemGroup>

</Project>
17 changes: 11 additions & 6 deletions src/Pasper/IIgnoreAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Pasper;

/// <summary>
/// A simple marker interface for defining proxies of the <see cref="IgnoreAttribute"/> type.
/// </summary>
public interface IIgnoreAttribute;
using System.Diagnostics.CodeAnalysis;

namespace Pasper;

/// <summary>
/// A simple marker interface for defining proxies of the <see cref="IgnoreAttribute"/> type.
/// </summary>
[SuppressMessage("Design", "CA1040:Avoid empty interfaces", Justification = "This is a marker interface.")]
[SuppressMessage("Naming", "CA1711:Identifiers should not have incorrect suffix",
Justification = "This is an interface representing an attribute.")]
public interface IIgnoreAttribute;
10 changes: 7 additions & 3 deletions src/Pasper/ISerializedAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Pasper;

using System.Diagnostics.CodeAnalysis;

namespace Pasper;

/// <summary>
/// Defines how members are serialized.
/// </summary>
[SuppressMessage("Naming", "CA1711:Identifiers should not have incorrect suffix",
Justification = "This is an interface representing an attribute.")]
public interface ISerializedAttribute
{
/// <summary>
/// The name of the member when serialized.
/// </summary>
string Name { get; set; }
string Name { get; }
}
51 changes: 5 additions & 46 deletions src/Pasper/Pasper.csproj
Original file line number Diff line number Diff line change
@@ -1,48 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
<Title>$(AssemblyName)</Title>
<Version>2023.4.10</Version>
<PackageVersion>$(AssemblyVersion)</PackageVersion>
<Authors>tacosontitan</Authors>
<Copyright>Copyright © 2023 tacosontitan and contibutors</Copyright>
<PackageProjectUrl>https://github.com/tacosontitan/Pasper</PackageProjectUrl>
<RepositoryUrl>https://github.com/tacosontitan/Pasper</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>provider;agnostic;serialization;proxy;json;xml;yaml;binary;toml;cbor</PackageTags>
<PackageReleaseNotes>Initial release.</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<AssemblyVersion>$(PackageVersion)</AssemblyVersion>
<FileVersion>$(PackageVersion)</FileVersion>
<Description>A lightweight, provider agnostic, serialization proxy designed to simplify serialization definitions.</Description>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<IncludeSymbols>True</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\LICENSE">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>


<PropertyGroup>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</PropertyGroup>

</Project>
136 changes: 68 additions & 68 deletions src/Pasper/Reflection/SerializedExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace Pasper.Reflection;

/// <summary>
/// Defines extension methods for determining if a member should be serialized.
/// </summary>
public static class SerializedExtensions
{
/// <summary>
/// Determines if the specified field should be serialized.
/// </summary>
/// <param name="source">The field to check.</param>
/// <param name="name">The name of the field to use when serializing.</param>
/// <returns><see langword="true"/> if the field should be serialized; otherwise, <see langword="false"/>.</returns>
public static bool IsSerialized(this FieldInfo source, out string name)
{
if (source is null)
throw new ArgumentNullException(nameof(source), "The field information cannot be null.");

name = string.Empty;
IEnumerable<object> attributes = source.GetCustomAttributes();
object? boxedSerializedAttribute = attributes?.SingleOrDefault(ImplementsSerializedInterface);
if (boxedSerializedAttribute is null)
return false;

var serializedAttribute = (ISerializedAttribute)boxedSerializedAttribute;
name = string.IsNullOrWhiteSpace(serializedAttribute.Name)
? source.Name
: serializedAttribute.Name;

return true;
}

/// <summary>
/// Determines if the specified property should be serialized.
/// </summary>
/// <param name="source">The property to check.</param>
/// <param name="name">The name of the property to use when serializing.</param>
/// <returns><see langword="true"/> if the property should be serialized; otherwise, <see langword="false"/>.</returns>
public static bool IsSerialized(this PropertyInfo source, out string name)
{
if (source is null)
throw new ArgumentNullException(nameof(source), "The property information cannot be null.");

name = string.Empty;
IEnumerable<object> attributes = source.GetCustomAttributes();
object? boxedSerializedAttribute = attributes?.SingleOrDefault(ImplementsSerializedInterface);
if (boxedSerializedAttribute is null)
return false;

var serializedAttribute = (ISerializedAttribute)boxedSerializedAttribute;
name = string.IsNullOrWhiteSpace(serializedAttribute.Name)
? source.Name
: serializedAttribute.Name;

return true;
}

private static bool ImplementsSerializedInterface(object attribute)
{
Type attributeType = attribute.GetType();
return typeof(ISerializedAttribute).IsAssignableFrom(attributeType);
}
}
// using System;
// using System.Collections.Generic;
// using System.Linq;
// using System.Reflection;
//
// namespace Pasper.Reflection;
//
// /// <summary>
// /// Defines extension methods for determining if a member should be serialized.
// /// </summary>
// public static class SerializedExtensions
// {
// /// <summary>
// /// Determines if the specified field should be serialized.
// /// </summary>
// /// <param name="source">The field to check.</param>
// /// <param name="name">The name of the field to use when serializing.</param>
// /// <returns><see langword="true"/> if the field should be serialized; otherwise, <see langword="false"/>.</returns>
// public static bool IsSerialized(this FieldInfo source, out string name)
// {
// if (source is null)
// throw new ArgumentNullException(nameof(source), "The field information cannot be null.");
//
// name = string.Empty;
// IEnumerable<object> attributes = source.GetCustomAttributes();
// object? boxedSerializedAttribute = attributes?.SingleOrDefault(ImplementsSerializedInterface);
// if (boxedSerializedAttribute is null)
// return false;
//
// var serializedAttribute = (ISerializedAttribute)boxedSerializedAttribute;
// name = string.IsNullOrWhiteSpace(serializedAttribute.Name)
// ? source.Name
// : serializedAttribute.Name;
//
// return true;
// }
//
// /// <summary>
// /// Determines if the specified property should be serialized.
// /// </summary>
// /// <param name="source">The property to check.</param>
// /// <param name="name">The name of the property to use when serializing.</param>
// /// <returns><see langword="true"/> if the property should be serialized; otherwise, <see langword="false"/>.</returns>
// public static bool IsSerialized(this PropertyInfo source, out string name)
// {
// if (source is null)
// throw new ArgumentNullException(nameof(source), "The property information cannot be null.");
//
// name = string.Empty;
// IEnumerable<object> attributes = source.GetCustomAttributes();
// object? boxedSerializedAttribute = attributes?.SingleOrDefault(ImplementsSerializedInterface);
// if (boxedSerializedAttribute is null)
// return false;
//
// var serializedAttribute = (ISerializedAttribute)boxedSerializedAttribute;
// name = string.IsNullOrWhiteSpace(serializedAttribute.Name)
// ? source.Name
// : serializedAttribute.Name;
//
// return true;
// }
//
// private static bool ImplementsSerializedInterface(object attribute)
// {
// Type attributeType = attribute.GetType();
// return typeof(ISerializedAttribute).IsAssignableFrom(attributeType);
// }
// }
14 changes: 4 additions & 10 deletions src/Pasper/SerializedAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,14 @@ namespace Pasper;
/// <summary>
/// Defines a simplified common attribute for defining how members should be serialized.
/// </summary>
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
public class SerializedAttribute
/// <param name="name">The name of the member when serialized.</param>
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
public sealed class SerializedAttribute(string name)
: Attribute,
ISerializedAttribute
{
/// <summary>
/// Creates a new <see cref="SerializedAttribute"/> instance.
/// </summary>
/// <param name="name">The name of the member when serialized.</param>
public SerializedAttribute(string name) =>
Name = name;

/// <summary>
/// Gets or sets the name of the member when serialized.
/// </summary>
public string Name { get; set; }
public string Name { get; } = name;
}
Loading

0 comments on commit d13fedd

Please sign in to comment.