Skip to content
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
52 changes: 52 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# .editorconfig for a C# project

# Indicates that this is the root file and no parent files should be considered
root = true

# General settings for all files
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

# Settings for C# files
[*.cs]
# Use predefined types (e.g. int instead of Int32) when the type is obvious
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion

# Do not require "this." qualification for members
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion

# Opening brace on a new line for all types (methods, classes, etc.)
csharp_new_line_before_open_brace = all:warning

# Enforce modifier order (e.g. public static void → correct order)
csharp_preferred_modifier_order = public, protected, private, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, volatile, async:error

# Use 'var' for built-in types and when the type is apparent
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = false:suggestion

# Sort 'using' directives with System namespaces first
dotnet_sort_system_directives_first = true

# Do not enforce any specific file header
file_header_template = unset

# Require braces on a new line and discourage single-line embedded statements
csharp_style_allow_embedded_statements_on_same_line = false:warning

# Indentation rules for switch/case and labels
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = flush_left

# Set maximum line length (optional but often recommended)
max_line_length = 120
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.cs text eol=lf
*.csproj text eol=lf
*.yml text eol=lf
*.xml text eol=lf
53 changes: 49 additions & 4 deletions .github/workflows/dotnet-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ name: .NET Tests

on:
push:
branches:
- main
pull_request:
branches:
- main



jobs:
build-and-test:
runs-on: ubuntu-latest


steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.CODE_STYLE }}

- name: Setup .NET
uses: actions/setup-dotnet@v3
Expand All @@ -24,6 +25,50 @@ jobs:
- name: Restore dependencies
run: dotnet restore T2dMath.sln

- name: Format code
run: dotnet format whitespace T2dMath.sln

- name: Format code style
run: dotnet format style T2dMath.sln

- name: Verify formatting
run: dotnet format T2dMath.sln --verify-no-changes

- name: Check token
env:
GITHUB_TOKEN: ${{ secrets.CODE_STYLE }}
run: echo "Token length is ${#GITHUB_TOKEN}"

- name: Show context info
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
echo "Branch: $BRANCH_NAME"
git remote -v
git status

- name: Commit and push formatting changes
env:
GITHUB_TOKEN: ${{ secrets.CODE_STYLE }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
echo "Branch: $BRANCH_NAME"

git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

git checkout -B "$BRANCH_NAME"

git add .
git commit -m "Auto-format code" || echo "No changes to commit"

git pull --rebase origin "$BRANCH_NAME"

git push origin "$BRANCH_NAME"




- name: Build the project
run: dotnet build T2dMath.sln --configuration Release --no-restore

Expand Down
30 changes: 14 additions & 16 deletions T2dMath.ILogAlgorithm/IGridTransformation.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace T2dMath.ILogAlgorithm
{
public interface IGridTransformation
{
double[] Transform(
double[] irregular_depth,
double[] curve_value,
double[] regular_depth_grid,
object[] param
);
}
}
using System;
using System.Collections.Generic;
using System.Text;

namespace T2dMath.ILogAlgorithm {
public interface IGridTransformation {
double[] Transform(
double[] irregular_depth,
double[] curve_value,
double[] regular_depth_grid,
object[] param
);
}
}
22 changes: 10 additions & 12 deletions T2dMath.ILogAlgorithm/ILogAlgorithm.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System;

namespace T2dMath.IAlgorithm
{
/// <summary>
///
/// </summary>
public interface ILogAlgorithm
{
double[] AlgorithmProcessor(double[] reference_curve, double[][] curves_in, object[] param);
}
}
using System;

namespace T2dMath.IAlgorithm {
/// <summary>
///
/// </summary>
public interface ILogAlgorithm {
double[] AlgorithmProcessor(double[] reference_curve, double[][] curves_in, object[] param);
}
}
22 changes: 10 additions & 12 deletions T2dMath.ILogAlgorithm/ILogTransformation.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System;

namespace T2dMath.ILogAlgorithm
{
/// <summary>
///
/// </summary>
public interface ILogTransformation
{
double[] Transformation(double[] reference_curve, double[][] input_curves, object[] param);
}
}
using System;

namespace T2dMath.ILogAlgorithm {
/// <summary>
///
/// </summary>
public interface ILogTransformation {
double[] Transformation(double[] reference_curve, double[][] input_curves, object[] param);
}
}
16 changes: 8 additions & 8 deletions T2dMath.ILogAlgorithm/T2dMath.ILogAlgorithm.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
</PropertyGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
</PropertyGroup>
</Project>
40 changes: 18 additions & 22 deletions T2dMath.LogAlgorithm/Abstract/ALogOneCurveInput.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using T2dMath.LogAlgorithm.Abstract;

namespace T2dMath.IAlgorithm
{
public abstract class ALogOneCurveInput : ALogTransformation
{
protected abstract double[] Calculate(double[] reference_curve, double[] input_curve);

protected override double[] Calculate(double[] reference_curve, double[][] input_curves)
{
if (input_curves.Length != 1)
{
return Enumerable.Repeat(double.NaN, reference_curve.Length).ToArray();
}
return Calculate(reference_curve, input_curves[0]);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using T2dMath.LogAlgorithm.Abstract;

namespace T2dMath.IAlgorithm {
public abstract class ALogOneCurveInput : ALogTransformation {
protected abstract double[] Calculate(double[] reference_curve, double[] input_curve);

protected override double[] Calculate(double[] reference_curve, double[][] input_curves) {
if (input_curves.Length != 1) {
return Enumerable.Repeat(double.NaN, reference_curve.Length).ToArray();
}
return Calculate(reference_curve, input_curves[0]);
}
}
}
55 changes: 26 additions & 29 deletions T2dMath.LogAlgorithm/Abstract/ALogPoint2Point.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace T2dMath.IAlgorithm
{
/// <summary>
/// Алгоритмы поточечного пересчёта одной кривой в другую
/// </summary>
public abstract class ALogPoint2Point : ALogOneCurveInput
{
protected abstract double Calculate(double reference_curve, double input_curve);

protected override double[] Calculate(double[] reference_curve, double[] input_curve)
{
var n = reference_curve.Length;

double[] result = Enumerable
.Range(0, n)
.AsParallel()
.Select(i => Calculate(reference_curve[i], input_curve[0]))
.ToArray();

return result;
}
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace T2dMath.IAlgorithm {
/// <summary>
/// Алгоритмы поточечного пересчёта одной кривой в другую
/// </summary>
public abstract class ALogPoint2Point : ALogOneCurveInput {
protected abstract double Calculate(double reference_curve, double input_curve);

protected override double[] Calculate(double[] reference_curve, double[] input_curve) {
var n = reference_curve.Length;

double[] result = Enumerable
.Range(0, n)
.AsParallel()
.Select(i => Calculate(reference_curve[i], input_curve[0]))
.ToArray();

return result;
}
}
}
47 changes: 22 additions & 25 deletions T2dMath.LogAlgorithm/Abstract/ALogTransformation.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using T2dMath.ILogAlgorithm;

namespace T2dMath.LogAlgorithm.Abstract
{
public abstract class ALogTransformation : ILogTransformation
{
protected virtual void InitOptions(object[] param) { }

protected abstract double[] Calculate(double[] reference_curve, double[][] curves_in);

public double[] Transformation(
double[] reference_curve,
double[][] input_curves,
object[] param
)
{
InitOptions(param);
return Calculate(reference_curve, input_curves);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using T2dMath.ILogAlgorithm;

namespace T2dMath.LogAlgorithm.Abstract {
public abstract class ALogTransformation : ILogTransformation {
protected virtual void InitOptions(object[] param) { }

protected abstract double[] Calculate(double[] reference_curve, double[][] curves_in);

public double[] Transformation(
double[] reference_curve,
double[][] input_curves,
object[] param
) {
InitOptions(param);
return Calculate(reference_curve, input_curves);
}
}
}
Loading
Loading