Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development -> Main #9

Merged
merged 2 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 33 additions & 57 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,12 @@ root = true

# All files
[*]
charset = utf-8
max_line_length = 100
end_of_line = crlf
indent_size = 4
indent_style = space
insert_final_newline = false
trim_trailing_whitespace = true

# Xml files
[*.xml]
indent_size = 2

# YML files
[*.yml]
indent_size = 2

# YML files
[*.csproj]
indent_size = 2

# JSON files
[*.json]
indent_size = 2

# C# files
[*.cs]

Expand All @@ -43,7 +25,7 @@ insert_final_newline = false
[*.{cs,vb}]

# Organize usings
dotnet_separate_import_directive_groups = false
dotnet_separate_import_directive_groups = true
dotnet_sort_system_directives_first = true
file_header_template = unset

Expand Down Expand Up @@ -122,7 +104,7 @@ csharp_style_conditional_delegate_call = true:suggestion

# Modifier preferences
csharp_prefer_static_local_function = true:warning
csharp_preferred_modifier_order = public, private, protected, internal, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, volatile, async:silent
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent

# Code-block preferences
csharp_prefer_braces = true:silent
Expand Down Expand Up @@ -274,63 +256,63 @@ dotnet_naming_rule.non_field_members_should_be_pascalcase.style = pascalcase

dotnet_naming_symbols.interfaces.applicable_kinds = interface
dotnet_naming_symbols.interfaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interfaces.required_modifiers =
dotnet_naming_symbols.interfaces.required_modifiers =

dotnet_naming_symbols.enums.applicable_kinds = enum
dotnet_naming_symbols.enums.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.enums.required_modifiers =
dotnet_naming_symbols.enums.required_modifiers =

dotnet_naming_symbols.events.applicable_kinds = event
dotnet_naming_symbols.events.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.events.required_modifiers =
dotnet_naming_symbols.events.required_modifiers =

dotnet_naming_symbols.methods.applicable_kinds = method
dotnet_naming_symbols.methods.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.methods.required_modifiers =
dotnet_naming_symbols.methods.required_modifiers =

dotnet_naming_symbols.properties.applicable_kinds = property
dotnet_naming_symbols.properties.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.properties.required_modifiers =
dotnet_naming_symbols.properties.required_modifiers =

dotnet_naming_symbols.public_fields.applicable_kinds = field
dotnet_naming_symbols.public_fields.applicable_accessibilities = public, internal
dotnet_naming_symbols.public_fields.required_modifiers =
dotnet_naming_symbols.public_fields.required_modifiers =

dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private, protected, protected_internal, private_protected
dotnet_naming_symbols.private_fields.required_modifiers =
dotnet_naming_symbols.private_fields.required_modifiers =

dotnet_naming_symbols.private_static_fields.applicable_kinds = field
dotnet_naming_symbols.private_static_fields.applicable_accessibilities = private, protected, protected_internal, private_protected
dotnet_naming_symbols.private_static_fields.required_modifiers = static

dotnet_naming_symbols.types_and_namespaces.applicable_kinds = namespace, class, struct, interface, enum
dotnet_naming_symbols.types_and_namespaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types_and_namespaces.required_modifiers =
dotnet_naming_symbols.types_and_namespaces.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =
dotnet_naming_symbols.non_field_members.required_modifiers =

dotnet_naming_symbols.type_parameters.applicable_kinds = namespace
dotnet_naming_symbols.type_parameters.applicable_accessibilities = *
dotnet_naming_symbols.type_parameters.required_modifiers =
dotnet_naming_symbols.type_parameters.required_modifiers =

dotnet_naming_symbols.private_constant_fields.applicable_kinds = field
dotnet_naming_symbols.private_constant_fields.applicable_accessibilities = private, protected, protected_internal, private_protected
dotnet_naming_symbols.private_constant_fields.required_modifiers = const

dotnet_naming_symbols.local_variables.applicable_kinds = local
dotnet_naming_symbols.local_variables.applicable_accessibilities = local
dotnet_naming_symbols.local_variables.required_modifiers =
dotnet_naming_symbols.local_variables.required_modifiers =

dotnet_naming_symbols.local_constants.applicable_kinds = local
dotnet_naming_symbols.local_constants.applicable_accessibilities = local
dotnet_naming_symbols.local_constants.required_modifiers = const

dotnet_naming_symbols.parameters.applicable_kinds = parameter
dotnet_naming_symbols.parameters.applicable_accessibilities = *
dotnet_naming_symbols.parameters.required_modifiers =
dotnet_naming_symbols.parameters.required_modifiers =

dotnet_naming_symbols.public_constant_fields.applicable_kinds = field
dotnet_naming_symbols.public_constant_fields.applicable_accessibilities = public, internal
Expand All @@ -346,47 +328,41 @@ dotnet_naming_symbols.private_static_readonly_fields.required_modifiers = readon

dotnet_naming_symbols.local_functions.applicable_kinds = local_function
dotnet_naming_symbols.local_functions.applicable_accessibilities = *
dotnet_naming_symbols.local_functions.required_modifiers =
dotnet_naming_symbols.local_functions.required_modifiers =

# Naming styles

dotnet_naming_style.pascalcase.required_prefix =
dotnet_naming_style.pascalcase.required_suffix =
dotnet_naming_style.pascalcase.word_separator =
dotnet_naming_style.pascalcase.required_prefix =
dotnet_naming_style.pascalcase.required_suffix =
dotnet_naming_style.pascalcase.word_separator =
dotnet_naming_style.pascalcase.capitalization = pascal_case

dotnet_naming_style.ipascalcase.required_prefix = I
dotnet_naming_style.ipascalcase.required_suffix =
dotnet_naming_style.ipascalcase.word_separator =
dotnet_naming_style.ipascalcase.required_suffix =
dotnet_naming_style.ipascalcase.word_separator =
dotnet_naming_style.ipascalcase.capitalization = pascal_case

dotnet_naming_style.tpascalcase.required_prefix = T
dotnet_naming_style.tpascalcase.required_suffix =
dotnet_naming_style.tpascalcase.word_separator =
dotnet_naming_style.tpascalcase.required_suffix =
dotnet_naming_style.tpascalcase.word_separator =
dotnet_naming_style.tpascalcase.capitalization = pascal_case

dotnet_naming_style._camelcase.required_prefix = _
dotnet_naming_style._camelcase.required_suffix =
dotnet_naming_style._camelcase.word_separator =
dotnet_naming_style._camelcase.required_suffix =
dotnet_naming_style._camelcase.word_separator =
dotnet_naming_style._camelcase.capitalization = camel_case

dotnet_naming_style.camelcase.required_prefix =
dotnet_naming_style.camelcase.required_suffix =
dotnet_naming_style.camelcase.word_separator =
dotnet_naming_style.camelcase.required_prefix =
dotnet_naming_style.camelcase.required_suffix =
dotnet_naming_style.camelcase.word_separator =
dotnet_naming_style.camelcase.capitalization = camel_case

dotnet_naming_style.s_camelcase.required_prefix = s_
dotnet_naming_style.s_camelcase.required_suffix =
dotnet_naming_style.s_camelcase.word_separator =
dotnet_naming_style.s_camelcase.required_suffix =
dotnet_naming_style.s_camelcase.word_separator =
dotnet_naming_style.s_camelcase.capitalization = camel_case

# Arrangement of Attributes
# csharp_max_attribute_length_for_same_line = 2
csharp_keep_existing_attribute_arrangement = true
csharp_keep_existing_arrangement = true
csharp_place_type_attribute_on_same_line = if_owner_is_single_line
csharp_place_method_attribute_on_same_line = if_owner_is_single_line
csharp_place_attribute_on_same_line = if_owner_is_single_line
csharp_place_accessorholder_attribute_on_same_line = if_owner_is_single_line
csharp_place_accessor_attribute_on_same_line = if_owner_is_single_line
csharp_place_field_attribute_on_same_line = if_owner_is_single_line
# Custom

dotnet_diagnostic.CA1002.severity = suggestion
dotnet_diagnostic.CA1707.severity = suggestion
2 changes: 1 addition & 1 deletion .github/workflows/run-create-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
dotnet-version: '8.0.x'

- name: Restore dependencies
run: dotnet restore
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
dotnet-version: '8.0.x'

- name: Restore dependencies
run: dotnet restore
Expand Down
32 changes: 32 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Project>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<PublishAot>false</PublishAot>

<AnalysisLevel>latest</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<ReportAnalyzer>true</ReportAnalyzer>
<AnalysisMode>All</AnalysisMode>
<Features>strict</Features>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
<RunAnalyzersDuringLiveAnalysis>true</RunAnalyzersDuringLiveAnalysis>
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
<AccelerateBuildsInVisualStudio>false</AccelerateBuildsInVisualStudio>

<NoWarn>
$(NoWarn);
</NoWarn>
<NoError>
$(NoError);
</NoError>

</PropertyGroup>
</Project>
1 change: 1 addition & 0 deletions JacksonVeroneze.NET.Pagination.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
global.json = global.json
LICENSE = LICENSE
Directory.Build.props = Directory.Build.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{ADD83F01-F068-49AC-A640-041F05741739}"
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.0",
"version": "8.0.0",
"rollForward": "major",
"allowPrerelease": true
}
Expand Down
36 changes: 36 additions & 0 deletions src/JacksonVeroneze.NET.Pagination/Common/PageBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Collections.ObjectModel;

namespace JacksonVeroneze.NET.Pagination.Common;

public abstract record PageBase<TEntity, TPageInfo>
where TEntity : class
where TPageInfo : class
{
protected PageBase(List<TEntity>? data, TPageInfo pageInfo) :
this(data?.AsReadOnly(), pageInfo)
{
}

protected PageBase(ICollection<TEntity> data, TPageInfo pageInfo) :
this(((List<TEntity>)data)?.AsReadOnly(), pageInfo)
{
}

protected PageBase(IEnumerable<TEntity> data, TPageInfo pageInfo) :
this((data.ToList()).AsReadOnly(), pageInfo)
{
}

protected PageBase(ReadOnlyCollection<TEntity>? data, TPageInfo pageInfo)
{
ArgumentNullException.ThrowIfNull(data);
ArgumentNullException.ThrowIfNull(pageInfo);

Data = data;
PageInfo = pageInfo;
}

public ReadOnlyCollection<TEntity> Data { get; }

public TPageInfo PageInfo { get; }
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace JacksonVeroneze.NET.Pagination;
namespace JacksonVeroneze.NET.Pagination.Common;

public enum SortDirection
{
Expand Down
28 changes: 28 additions & 0 deletions src/JacksonVeroneze.NET.Pagination/Cursor/Page.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Collections.ObjectModel;
using JacksonVeroneze.NET.Pagination.Common;

namespace JacksonVeroneze.NET.Pagination.Cursor;

public record Page<TEntity> : PageBase<TEntity, PageInfo>
where TEntity : class
{
public Page(List<TEntity> data, PageInfo pageInfo)
: base(data, pageInfo)
{
}

public Page(ICollection<TEntity> data, PageInfo pageInfo)
: base(data, pageInfo)
{
}

public Page(IEnumerable<TEntity> data, PageInfo pageInfo)
: base(data, pageInfo)
{
}

public Page(ReadOnlyCollection<TEntity> data, PageInfo pageInfo)
: base(data, pageInfo)
{
}
}
18 changes: 18 additions & 0 deletions src/JacksonVeroneze.NET.Pagination/Cursor/PageInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace JacksonVeroneze.NET.Pagination.Cursor;

public record PageInfo
{
public PageInfo(bool hasMore, string? cursor)
{
if (hasMore && string.IsNullOrWhiteSpace(cursor))
{
throw new ArgumentNullException(nameof(cursor));
}

HasMore = hasMore;
Cursor = cursor;
}

public bool HasMore { get; }
public string? Cursor { get; }
}
30 changes: 30 additions & 0 deletions src/JacksonVeroneze.NET.Pagination/Cursor/PaginationParameters.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using JacksonVeroneze.NET.Pagination.Common;

namespace JacksonVeroneze.NET.Pagination.Cursor;

public record PaginationParameters
{
public PaginationParameters(int limit, string? cursor)
{
Guard.Against.NegativeOrZero(limit);

Limit = limit;
Cursor = cursor;
}

public PaginationParameters(int limit, string? cursor,
string? orderBy, SortDirection? direction) :
this(limit, cursor)
{
OrderBy = orderBy;
Direction = direction;
}

public int? Limit { get; }

public string? Cursor { get; }

public string? OrderBy { get; }

public SortDirection? Direction { get; }
}
Loading
Loading