Git Product home page Git Product logo

weihanli / weihanli.common Goto Github PK

View Code? Open in Web Editor NEW
229.0 10.0 86.0 24.42 MB

common tools, methods, extension methods, etc... .net 常用工具类,公共方法,常用扩展方法等,基础类库

Home Page: https://weihanli.github.io/WeihanLi.Common/index.html

License: Apache License 2.0

C# 99.17% PowerShell 0.03% Shell 0.12% HTML 0.68%
utility common extensions dotnet dotnetcore weihanli netstandard library csharp helpers

weihanli.common's Introduction

WeihanLi.Common

Build status

WeihanLi.Common Latest Stable

WeihanLi.Common Latest

Azure Pipelines Build Status

Github Actions Build Status

Intro

.NET Helpers, extensions, utility and more ...

Features

  • Dependence Injection(类比微软依赖注入框架自定义实现的依赖注入框架)
  • Fluent Aspects -- AOP implemented(基于动态代理实现的 AOP 框架)
  • Event Related(EventBus/EventQueue/EventStore)
  • Logging Framework(结合Serilog/微软日志框架实现的日志框架)
  • Dapper-like Ado.Net extensions(类似 Dapper 的 Ado.Net 扩展)
  • TOTP implement(TOTP算法实现)
  • and more ...

Release Notes

See pull requests list for changes https://github.com/WeihanLi/WeihanLi.Common/pulls?q=is%3Apr+is%3Amerged+base%3Amaster

Contact

Contact me if you need: [email protected]

weihanli.common's People

Contributors

weihanli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

weihanli.common's Issues

`CommandExecutor` enhancements

  • Add ExecuteCommandAndCapture/ExecuteCommandAndCaptureAsync for returning CommandResult
  • Add ConsoleHelper.PrintOutput extension for CommandResult
  • Rename EnsureSuccessfulExitCode to EnsureSuccessExitCode likes HttpResponseMessage.EnsureSuccessStatusCode()

Add net8.0 target

Add .NET 8.0 target support

  • Add net8.0 target for Common
  • Add net6.0 for extensions
    • Castle extensions
    • Serilog extensions

防SQL注入正则表达式的问题

数据库MSSQL Server,
使用的查询语句:select ArmId as Id,ArmName as Name from arm
位置:
WeihanLi.Common/Helpers/SecurityHelper.cs

使用两种表达式验证
IsSafeSqlString 方法都是返回false,
该方法不能用于执行sql语句前判断注入吗?

templating enhancements

  • support get value from the environment

For example:

var result = TemplateEngine.CreateDefault().RenderAsync("Hello {{$env USERNAME}}");
Console.WriteLine(result);

API changes:

public interface ITemplateRenderer
{
-     Task<string> RenderAsync(TemplateRenderContext template, object globals);
+     Task<string> RenderAsync(TemplateRenderContext template, object? globals = null);
}

Enable nullable reference types

Create this issue for tracking the nullable reference types.
Now all projects had enabled nullable reference types, but some API may not as expected, create issue for tracking these API

CommandLineParser

Simple command line parser to parse the command line input and avoid issue:
dotnet/command-line-api#1385

Refer to https://github.com/dotnet/command-line-api/blob/b4bbdd2869fb7d500b5d91e32c84cfa69eb3b645/src/System.CommandLine/Parsing/CliParser.cs#L40

Possible implement:

class CommandLineParer
{
    public static IEnumerable<string> SplitCommandLine(string commandLine)
    {
        var memory = commandLine.AsMemory();

        var startTokenIndex = 0;

        var pos = 0;

        var seeking = Boundary.TokenStart;
        var seekingQuote = Boundary.QuoteStart;

        while (pos < memory.Length)
        {
            var c = memory.Span[pos];

            if (char.IsWhiteSpace(c))
            {
                if (seekingQuote == Boundary.QuoteStart)
                {
                    switch (seeking)
                    {
                        case Boundary.WordEnd:
                            yield return CurrentToken();
                            startTokenIndex = pos;
                            seeking = Boundary.TokenStart;
                            break;

                        case Boundary.TokenStart:
                            startTokenIndex = pos;
                            break;
                    }
                }
            }
            else if (c == '\"')
            {
                if (seeking == Boundary.TokenStart)
                {
                    switch (seekingQuote)
                    {
                        case Boundary.QuoteEnd:
                            yield return CurrentToken();
                            startTokenIndex = pos;
                            seekingQuote = Boundary.QuoteStart;
                            break;

                        case Boundary.QuoteStart:
                            startTokenIndex = pos + 1;
                            seekingQuote = Boundary.QuoteEnd;
                            break;
                    }
                }
                else
                {
                    switch (seekingQuote)
                    {
                        case Boundary.QuoteEnd:
                            seekingQuote = Boundary.QuoteStart;
                            break;

                        case Boundary.QuoteStart:
                            seekingQuote = Boundary.QuoteEnd;
                            break;
                    }
                }
            }
            else if (seeking == Boundary.TokenStart && seekingQuote == Boundary.QuoteStart)
            {
                seeking = Boundary.WordEnd;
                startTokenIndex = pos;
            }

            Advance();

            if (IsAtEndOfInput())
            {
                switch (seeking)
                {
                    case Boundary.TokenStart:
                        break;
                    default:
                        yield return CurrentToken();
                        break;
                }
            }
        }

        void Advance() => pos++;

        string CurrentToken()
        {
            return memory.Slice(startTokenIndex, IndexOfEndOfToken()).ToString().Trim('"');
        }

        int IndexOfEndOfToken() => pos - startTokenIndex;

        bool IsAtEndOfInput() => pos == memory.Length;
    }

    private enum Boundary
    {
        TokenStart,
        WordEnd,
        QuoteStart,
        QuoteEnd
    }
}

数据库扩展问题

logging refact

  • add logging event
  • add logging formatter
  • add logging enricher
  • add logging builder

Add more method to IRepository

Add the following methods to IRepository interface:
int Update(TEntity entity, params Expression<Func<TEntity, object>>[] propertyExpressions);
int Update(TEntity entity, params string[] propertyNames);
Task UpdateAsync(TEntity entity, Expression<Func<TEntity, object>>[] propertyExpressions, CancellationToken cancellationToken = default);
Task UpdateAsync(TEntity entity, string[] propertyNames, CancellationToken cancellationToken = default);

Purpose:
Make application service layer depend the IRepository instead of the IEFRepository layer so it decouples the domain service and the infrusture.

refactor events

  • Currently, the event needs a strong-typed event instance that implements IEventBase, maybe we could remove the constraint to make it much easier to use.
  • Secondly, maybe we could add headers/properties support for better flexibility
  • Event data serializer customize to support distributed events(not needed for local event processing)
  • It would be great to support routing(out of scope)

https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md

AOP abstracts

add AOP abstracts and implement for AspectCore and Castle

1.1.0 Road Map

  • Built-In IoC
  • Built-In AOP
  • Built-In Repository
  • Built-In Logging
  • Built-In TOTP implement
  • Built-In EventBus
  • Built-In PipelineBuilder
  • Built-In Cron
  • #120
  • #121
  • #170
  • And More ...

Add runtime info for ApplicationHelper

**.NET information
Version: 7.0.0
FrameworkDescription: .NET 7.0.0
Libraries version: 7.0.0
Libraries hash: d099f075e45d2aa6007a22b71b45a08758559f80

**Environment information
ProcessorCount: 12
OSArchitecture: X64
OSDescription: Microsoft Windows 10.0.19044
OSVersion: Microsoft Windows NT 10.0.19044.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.