GithubHelp home page GithubHelp logo

justnrik / netutilities Goto Github PK

View Code? Open in Web Editor NEW
36.0 6.0 19.0 349 KB

A lot of extension methods that may be useful for someone.

C# 100.00%
hacktoberfest csharp netcore netcore5 utilities utilities-library

netutilities's People

Contributors

arahaan avatar emzi0767 avatar erik-bard avatar justnrik 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

netutilities's Issues

Adding utility

Sir, I am a Junior .Net Developer I want some experience on contributing to open source projects because I am preparing for GSOC.

Implementation of Mapper

Mapper

This type is a wrapper over System.Type to provide high performance runtime manipulation on the given type, for example, getting/setting the value of a property without the expensive cost of reflection using the magic of Linq.Expressions. Also, each type will contain some metadata such as attributes.

Help Wanted

Currently, I need to do major tests and add more features for more runtime manipulation. Any contribution/review is appreciated. Since this class makes a lot of one-time reflection calls, it want to keep it as lazy as possible, since not everyone will use every single member of this class so the allocation cost is lowered.

Create Wiki

So you can more effectively document the utilities that you are providing.

Is NetUtilities.xml Needed?

The .NET SDK (in this case the project uses the .NET 5 SDK) I think it is more maintainable if the .NET SDK automatically generates the documentation xml file.

However is it required for anything, or was it just to try to avoid having it generate the file?

With a single target framework and the fact that OutputPath is not changed in the csproj I think it's ok to replace it with <GenerateDocumentationFile>true</GenerateDocumentationFile>.

I am working on a clone at the moment to test that, as well as split out some things that compile for .NET Standard 2.0 as well that can be used for things that should theoretically work for projects targeting .NET Standard (like the MemoryStream and Process Extensions I made before).

This is due to the fact that when this is published to nuget.org I would really like to use the NetStandard version with only the things that can compile under .NET Standard before pushed so that way those projects can drop their own copy of them for the ones I pull requested for here.

I will also retry the setup to try to get packing for nupkg's working too so dotnet pack can be used and all the needed information would be filled in (even if it requires an Directory.Build.props file just so that the csproj's are as small and clean as possible.

So here is my plan:

  • move everything that can be compiled under .NET Standard 2.0 to NetUtilities.NetStandard (it will only target .NET Standard 2.0 which should be usable with netcoreapp2.0+, plus it would allow possibly some of the extensions to be used with analyzers / source generators as well since they require targeting netstandard2.0).
  • ProjectReference NetUtilities.NetStandard inside of NetUtilities.
  • Set up the projects for SDK generated docs at build time.
  • Look into string resources for being able to localize exception messages on the extensions.
  • And finally, prepare the projects NetUtilities.NetStandard and NetUtilities for nuget.org deployment.

Note: I will check and see for all the places that uses CompilerServices.Unsafe to see if they compile under .NET Standard, if they do with the 5.0.0 package for it it will PackageReference it, if not then those will be .NET 5 specific extensions and won't be included in the NetStandard project.

Implementation of (U)Int24

Int24 / UInt24 Types

These types are for representing 24 bits integers for some use cases, a common example would be the representation of an RGB Color.

Help Wanted

I need to test if the types are working properly and make as many optimizations as possible to make them as performant as possible.

Wanna contribute to your library but can't enable the preview features in c#

Hi,
Can I contribute to the Library? It seems small enough for me to practice my C# skills while learning latest language features at the same time.

I tried to build the solution in VS2019 but I'm getting the error which says : To use preview language feature, select preview language version. On StackOverflow, it was recommended to add some lines to csproj file.

https://stackoverflow.com/questions/53633538/how-to-enable-nullable-reference-types-feature-of-c-sharp-8-0-for-the-whole-proj

<PropertyGroup>
  ...
  <NullableReferenceTypes>true</NullableReferenceTypes>
  <LangVersion>8.0</LangVersion>
</PropertyGroup>

These lines were already there in csproj file of this solution. Any help?

Test Project Missing

It looks like the test project is missing from the solution. Can it be added to the repository so tests can be written and ran?

Mapper Proposed API

The implementation of this type should satisfy the followings:

Note: If you want to contribute to this issue, please do it on feature-Mapper branch, Thanks.

1. Expose the following properties:

  • ReadOnlyList<ConstructorData> Constructors
  • ReadOnlyList<EventData> Events
  • ReadOnlyList<FieldData> Fields
  • ReadOnlyList<MethodData> Methods
  • ReadOnlyList<PropertyData> Properties

2. Data members should expose:

ConstructorData

  • ReadOnlyList<ParameterInfo> Parameters
  • bool IsDefaultConstructor
  • object CreateInstance()
  • T CreateInstance<T>()
  • object CreateInstance(object[])
  • T CreateInstance<T>(object[])

EventData

  • Type EventType
  • Delegate[] GetInvocationList()
  • void AddHandler(Delegate)
  • void RemoveHandler(Delegate)
  • void RaiseEvent(object[]?)

FieldData

  • Type ReturnType
  • object GetValue(object?)
  • void SetValue(object?, object?)

MethodData

  • Type ReturnType
  • object? Invoke()
  • object? Invoke(object[])

PropertyData

  • Type ReturnType
  • bool IsIndexer
  • MethodData GetMethod
  • MethodData SetMethod
  • object GetValue(object?)
  • void SetValue(object?, object?)

3. Add tests to ensure all the implementation is correct.

  • ReadOnlyList<ConstructorData> Constructors
  • ReadOnlyList<EventData> Events
  • ReadOnlyList<FieldData> Fields
  • ReadOnlyList<MethodData> Methods
  • ReadOnlyList<PropertyData> Properties
  • ConstructorData
  • EventData
  • FieldData
  • MethodData
  • PropertyData

Cache Reflection Extensions

If you want to, you can cache your reflection extensions. Something like this:

public static bool HasDefaultConstructor(this Type type) { ... }

public static bool HasDefaultConstructor<T>() => HasDefaultConstructorCache<T>.Value;

internal static class HasDefaultConstructorCache<T>
{
  internal static bool Value = HasDefaultConstructor(typeof(T));
}

(U)Int24 Proposed API

The implementation of this type should satisfy the followings:

Note: If you help with this issue, please do it on feature-(U)Int24 branch, Thanks.

1. Add these constructors

  • Int24(byte)

  • Int24(sbyte)

  • Int24(short)

  • Int24(ushort)

  • Int24(int)

  • Int24(uint)

  • Int24(long)

  • Int24(ulong)

  • Int24(nint)

  • Int24(nuint)

  • Int24(UInt24)

  • Int24(byte[])

  • Int24(byte[], int)

  • Int24(ReadOnlySpan<byte>)

  • UInt24(byte)

  • UInt24(sbyte)

  • UInt24(short)

  • UInt24(ushort)

  • UInt24(int)

  • UInt24(uint)

  • UInt24(long)

  • UInt24(ulong)

  • UInt24(nint)

  • UInt24(nuint)

  • UInt24(Int24)

  • UInt24(byte[])

  • UInt24(byte[], int)

  • UInt24(ReadOnlySpan<byte>)

2. Properly implement the following interfaces:

Int24

  • IEquatable<Int24>
  • IComparable<Int24>
  • IConvertible
  • IComparable
  • IFormattable

UInt24

  • IEquatable<UInt24>
  • IComparable<UInt24>
  • IConvertible
  • IComparable
  • IFormattable

3. Add the following operators:

Unary Operators

  • Int24 operator +(Int24)
  • Int24 operator -(Int24)
  • UInt24 operator +(UInt24)

Bitwise Complement Operator

  • Int24 operator ~(Int24)
  • UInt24 operator ~(UInt24)

Cast Operators

Int24 -> Signed Number

  • explicit operator sbyte(Int24)
  • explicit operator short(Int24)
  • implicit operator int(Int24)
  • implicit operator long(Int24)

Int24 -> Unsigned Number

  • explicit operator byte(Int24)
  • explicit operator ushort(Int24)
  • explicit operator uint(Int24)
  • explicit operator ulong(Int24)

Signed Number -> Int24

  • explicit operator Int24(int)
  • explicit operator Int24(long)

Unsigned Number -> Int24

  • explicit operator Int24(uint)
  • explicit operator Int24(ulong)

UInt24 -> Int24

  • explicit operator Int24(UInt24)

UInt24 -> Signed Number

  • explicit operator sbyte(UInt24)
  • explicit operator short(UInt24)
  • implicit operator int(UInt24)
  • implicit operator long(UInt24)

UInt24 -> Unsigned Number

  • explicit operator byte(UInt24)
  • explicit operator ushort(UInt24)
  • implicit operator uint(UInt24)
  • implicit operator ulong(UInt24)

Signed Number -> UInt24

  • explicit operator UInt24(int)
  • explicit operator UInt24(long)

Unsigned Number -> UInt24

  • explicit operator UInt24(uint)
  • explicit operator UInt24(ulong)

Int24 -> UInt24

  • explicit operator UInt24(Int24)

Multiplication Operator

  • Int24 operator *(int, Int24)

  • Int24 operator *(Int24, int)

  • Int24 operator *(Int24, Int24)

  • UInt24 operator *(uint, UInt24)

  • UInt24 operator *(UInt24, uint)

  • UInt24 operator *(UInt24, UInt24)

Division Operator

  • Int24 operator /(int, Int24)

  • Int24 operator /(Int24, int)

  • Int24 operator /(Int24, Int24)

  • UInt24 operator /(uint, UInt24)

  • UInt24 operator /(UInt24, uint)

  • UInt24 operator /(UInt24, UInt24)

Remainder Operator

  • Int24 operator %(int, Int24)

  • Int24 operator %(Int24, int)

  • Int24 operator %(Int24, Int24)

  • UInt24 operator %(uint, UInt24)

  • UInt24 operator %(UInt24, uint)

  • UInt24 operator %(UInt24, UInt24)

Addition Operator

  • Int24 operator +(int, Int24)

  • Int24 operator +(Int24, int)

  • Int24 operator +(Int24, Int24)

  • UInt24 operator +(uint, UInt24)

  • UInt24 operator +(UInt24, uint)

  • UInt24 operator +(UInt24, UInt24)

Subtraction Operator

  • Int24 operator -(int, Int24)

  • Int24 operator -(Int24, int)

  • Int24 operator -(Int24, Int24)

  • UInt24 operator -(uint, UInt24)

  • UInt24 operator -(UInt24, uint)

  • UInt24 operator -(UInt24, UInt24)

Shift Operator

  • Int24 operator <<(Int24, int)

  • Int24 operator >>(Int24, int)

  • UInt24 operator <<(UInt24, uint)

  • UInt24 operator >>(UInt24, uint)

Integer Comparison Operators

  • bool operator ==(int, Int24)

  • bool operator ==(Int24, int)

  • bool operator ==(Int24, Int24)

  • bool operator !=(int, Int24)

  • bool operator !=(Int24, int)

  • bool operator !=(Int24, Int24)

  • bool operator <(int, Int24)

  • bool operator <(Int24, int)

  • bool operator <(Int24, Int24)

  • bool operator >(int, Int24)

  • bool operator >(Int24, int)

  • bool operator >(Int24, Int24)

  • bool operator <=(int, Int24)

  • bool operator <=(Int24, int)

  • bool operator <=(Int24, Int24)

  • bool operator >=(int, Int24)

  • bool operator >=(Int24, int)

  • bool operator >=(Int24, Int24)

  • bool operator ==(uint, UInt24)

  • bool operator ==(UInt24, uint)

  • bool operator ==(UInt24, UInt24)

  • bool operator !=(uint, UInt24)

  • bool operator !=(UInt24, uint)

  • bool operator !=(UInt24, UInt24)

  • bool operator <(uint, UInt24)

  • bool operator <(UInt24, uint)

  • bool operator <(UInt24, UInt24)

  • bool operator >(uint, UInt24)

  • bool operator >(UInt24, uint)

  • bool operator >(UInt24, UInt24)

  • bool operator <=(uint, UInt24)

  • bool operator <=(UInt24, uint)

  • bool operator <=(UInt24, UInt24)

  • bool operator >=(uint, UInt24)

  • bool operator >=(UInt24, uint)

  • bool operator >=(UInt24, UInt24)

Integer Logical Operators

  • Int24 operator &(int, Int24)

  • Int24 operator &(Int24, int)

  • Int24 operator &(Int24, Int24)

  • Int24 operator |(int, Int24)

  • Int24 operator |(Int24, int)

  • Int24 operator |(Int24, Int24)

  • Int24 operator ^(int, Int24)

  • Int24 operator ^(Int24, int)

  • Int24 operator ^(Int24, Int24)

  • UInt24 operator &(uint, UInt24)

  • UInt24 operator &(UInt24, uint)

  • UInt24 operator &(UInt24, UInt24)

  • UInt24 operator |(uint, UInt24)

  • UInt24 operator |(UInt24, uint)

  • UInt24 operator |(UInt24, UInt24)

  • UInt24 operator ^(uint, UInt24)

  • UInt24 operator ^(UInt24, uint)

  • UInt24 operator ^(UInt24, UInt24)

4. Add Parse and TryParse static methods and Min/Max Value constants

  • Int24 MaxValue

  • Int24 MinValue

  • Int24 Parse(string)

  • Int24 Parse(string, NumberStyles)

  • Int24 Parse(string, NumberStyles, IFormatProvider?)

  • bool TryParse(string, out Int24)

  • bool TryParse(string, NumberStyles, out Int24)

  • bool TryParse(string, NumberStyles, IFormatProvider?, out Int24)

  • UInt24 MaxValue

  • UInt24 MinValue

  • UInt24 Parse(string)

  • UInt24 Parse(string, NumberStyles)

  • UInt24 Parse(string, NumberStyles, IFormatProvider?)

  • bool TryParse(string, out UInt24)

  • bool TryParse(string, NumberStyles, out UInt24)

  • bool TryParse(string, NumberStyles, IFormatProvider?, out UInt24)

5. Add documentation to all public members (except operators)

  • Int24 Constructors

  • UInt24 Constructors

  • Int24 MaxValue

  • Int24 MinValue

  • Int24 Parse(string)

  • Int24 Parse(string, NumberStyles)

  • Int24 Parse(string, NumberStyles, IFormatProvider?)

  • bool TryParse(string, out Int24)

  • bool TryParse(string, NumberStyles, out Int24)

  • bool TryParse(string, NumberStyles, IFormatProvider?, out Int24)

  • UInt24 MaxValue

  • UInt24 MinValue

  • UInt24 Parse(string)

  • UInt24 Parse(string, NumberStyles)

  • UInt24 Parse(string, NumberStyles, IFormatProvider?)

  • bool TryParse(string, out UInt24)

  • bool TryParse(string, NumberStyles, out UInt24)

  • bool TryParse(string, NumberStyles, IFormatProvider?, out UInt24)

6. Add tests to ensure all the implementation is correct.

Int24

  • Add tests for Constructors
  • Add tests for Interfaces
  • Add tests for Unary Operators
  • Add tests for Bitwise Complement Operators
  • Add tests for Cast Operators
  • Add tests for Multiplication Operators
  • Add tests for Division Operators
  • Add tests for Remainder Operators
  • Add tests for Addition Operators
  • Add tests for Subtraction Operators
  • Add tests for Shift Operators
  • Add tests for Integer Comparison Operators
  • Add tests for Integer Logical Operators
  • Add tests for Parse
  • Add tests for TryParse

UInt24

  • Add tests for Constructors
  • Add tests for Interfaces
  • Add tests for Unary Operators
  • Add tests for Bitwise Complement Operators
  • Add tests for Cast Operators
  • Add tests for Multiplication Operators
  • Add tests for Division Operators
  • Add tests for Remainder Operators
  • Add tests for Addition Operators
  • Add tests for Subtraction Operators
  • Add tests for Shift Operators
  • Add tests for Integer Comparison Operators
  • Add tests for Integer Logical Operators
  • Add tests for Parse
  • Add tests for TryParse

Missing Documentation

Is there any documentation that will be helpful in collaboration with this project? The documentation is missing for this project so far. Can you guide me to possible resources which will allow me to contribute to this project?

Implementation of MutableString

MutableString

This type is nothing but a wrapper of StringBuilder class. The focus of this class is to improve string manipulation and provide more utilities that StringBuilder doesn't offer.

Help Wanted

Currently, I need to do major test to ensure everything works as intended, as well as make as many optimizations as possible. Suggestions for new members (properties/methods) into MutableStrings and tweaks in the current members are welcome as well.

Implementation of (Action|Bound)Scope

ActionScope and BoundScope

These types provides a scope in which an action is executed and then it will be undo in the end of the scope.

Usage example of ActionScope:

var foo = new Foo();
using (ActionScope<Foo>.Create(foo, x => x.Value = 1337, x => x.Value = 0))
    Console.WriteLine(foo.Value); // prints 1337

Console.WriteLine(foo.Value); // prints 0

Usage example of BoundScope:

Console.ForegroundColor = ConsoleColor.White;
using (BoundScope.Create(() => Console.ForegroundColor, ConsoleColor.Blue))
{
    Console.WriteLine("Hello in blue!");
}
Console.WriteLine("Hello in white!");

Remarks

The main difference from ActionScope and BoundScope is that a BoundScope stores the old value of an object's property/field and assigns the new value, then, when the scope is disposed, the old value is reassigned. ActionScope represents an arbitrary action defined by the user.

Help Wanted

I want to make tests to ensure it works as intended and make optimizations if needed.

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.