GithubHelp home page GithubHelp logo

scottdorman / cadru Goto Github PK

View Code? Open in Web Editor NEW
68.0 6.0 17.0 17.35 MB

A Microsoft .NET Framework toolkit

Home Page: http://scottdorman.github.io/cadru

License: Microsoft Public License

C# 100.00%
portable c-sharp microsoft net-core net-standard

cadru's Introduction

Cadru Build status Join the chat at https://gitter.im/scottdorman/cadru

What is Cadru?

Cadru is a collection of NuGet packages containing new APIs and extensions to the core .NET Framework to help complete your developer toolbox. It is designed to be cross-platform and targets .NET Standard 2.1.

What's in it?

Cadru is made up of the following packages:

Cadru.AspNetCore

Provides ASP.NET Core middleware and other extensions for request and/response logging.

NuGet downloads NuGet version

Cadru.AspNetCore.Mvc

Provides additional support for working with ASP.NET Core, such as custom view location expanders, support for IMetadataAware, and rendering enumerated types as SelectLists based on a UiHint attribute, and extensions to make working with state management a bit simpler.

NuGet downloads NuGet version

Cadru.AspNetCore.Mvc.TagHelpers

Provides additional ASP.NET Core TagHelpers.

NuGet downloads NuGet version

Cadru.Build.Tasks

Provides additional MSBuild tasks and is used to support assembly-build-versioning.

NuGet downloads NuGet version

Cadru.Caching

Provides a standard implementation for creating and using cache keys.

NuGet downloads NuGet version

Cadru.Collections

Provides additional collection classes and extensions.

NuGet downloads NuGet version

Cadru.Contracts

Provides static classes for representing program contracts as preconditions in a way that's compatible with System.Diagnostics.Contracts.

NuGet downloads NuGet version

Cadru.Core

Provides common extensions and new APIs for the .NET Framework.

NuGet downloads NuGet version

Cadru.Data

Provides a standard way to read Excel data and fixed width files.

NuGet downloads NuGet version

Cadru.Data.Annotations

Provides common data annotation attributes.

NuGet downloads NuGet version

Cadru.Data.Dapper

Provides a common database context and predicates for use with Dapper.

NuGet downloads NuGet version

Cadru.Environment

Provides support for determining framework versions, IIS version, and feature detection.

NuGet downloads NuGet version

Cadru.Extensions.FileProviders

Additional file providers and support for working with physical files and directories.

NuGet downloads NuGet version

Cadru.Net.Http

Provides transient error detection strategies for adding retry logic into your HttpClient calls and a UrlBuilder to help simplify building complex URLs.

NuGet downloads NuGet version

Cadru.Net.NetworkInformation

Provides access to network information and notification of network status changes.

NuGet downloads NuGet version

Cadru.Polly

Provides support for working with Polly policies, including a strategy for resilient database queries.

NuGet downloads NuGet version

Cadru.Postal

Provides classes for generating email using ASP.NET MVC Razor views.

NuGet downloads NuGet version

Cadru.Scim

Support for creating System for Cross-domain Identity Management (SCIM) filters.

NuGet downloads NuGet version

Cadru.UnitTest.Framework

Provides additional assert capabilities for MS Test.

NuGet downloads NuGet version

The following packages have been retired. They are still available on NuGet, but shouldn't be used.

  • Cadru.TransientFaultHandling - This package has been retired and should be replaced with *Cadru.Polly.
  • Cadru.Net - This package is renamed to *Cadru.Net.Http
  • Cadru.Core.Windows - This package is retired, and features migrated to Cadru.Environment, Cadru.IO, and Cadru.Net.NetworkInformation as appropriate.
  • Cadru.IO - This package will eventually be retired and replaced with Cadru.Extensions.FileProviders.

What's next for Cadru?

The most significant update planned will be support for .NET 5 when it releases in November. Until then, there are a handful of known tasks still left. See the Cadru 5.0 milestone for more details. There are only a few issues in there right now, but I will be adding more over time.

Why another library?

Although Cadru was released as an open source framework in July 2013, some of the APIs it contains were created as early as 2003 and have been used in a variety of real world solutions. These are things that I kept having to rewrite in the apps I was building. Rather than continuing to rewrite them, I decided to encapsulate them in a library and make it broadly available. Although Cadru grew from app development, I have rewritten everything with a focus on being an API rather than a jumbled collection of utilities. That means everything is (hopefully) well documented, cleanly written, and easy to use.

Documentation

There are also a lot of unit tests that show how to use the APIs which can be a good starting place as well. (My goal is to as be as close to 100% code coverage as possible. Obviously, that will always be a work in progress.)

The long-term goal is to put the documentation online somewhere (probably as wiki pages hosted in the repository), but I don't have a time frame for when that will be complete. Until then, the source code is fully commented using XML documentation comments to provide IntelliSense support in Visual Studio.

Bugs and feature requests

Do you have a bug or a feature request? Please use the issue tracker and search for existing and closed issues. If your problem or request isn't addressed yet, go ahead and open a new issue.

Contributing

You can also get involved and fork the repository to submit your own pull requests. (More detailed contributor guidelines will be available soon.)

Versioning

For transparency and to maintain backward compatibility (as much as possible), Cadru uses the Semantic Versioning guidelines.

Creators

Copyright and license

Code and documentation copyright 2001-2020 Scott Dorman. Code is licensed under the Microsoft Public License, use it as you wish (but please provide some credit somewhere in your app.) Documentation is released under Creative Commons.

cadru's People

Contributors

dependabot[bot] avatar gitter-badger avatar scottdorman 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cadru's Issues

Add a Partition method for enumerables

Add a method which partitions an enumerable into a collection of smaller enumerable collections all of a certain size. This is different from Slice, which returns a segment, in that

int[] numbers = { 0, 30, 20, 15, 90, 85, 40, 75 };
var partitions = numbers.Partition(3).ToArray();

Assert.AreEqual(3, partitions.Length);
CollectionAssert.AreEqual(new[] { 0, 30, 20 }, partitions[0].ToArray());
CollectionAssert.AreEqual(new[] { 15, 90, 85 }, partitions[1].ToArray());
CollectionAssert.AreEqual(new[] { 40, 75 }, partitions[2].ToArray());

HttpExtensions needs a CreateMessage method

A CreateMessage extension method on HttpClient needs to be created so that a MessageRequest can be created with query string parameters. This allows a MessageRequest, and more specifically the Uri of the request to be easily created with query string parameters to get around the limitations of Uri and the HttpClient.GetAsync method.

Add a Range(T) class.

Add a class which allows easy creation of a range of values. The range should be similar to a mathematical interval and should be able to include or exclude either endpoint (using standard interval notation), provide intersection and union operations, and be enumerable using a default enumeration function or a custom function.

Add DateTime and DateTimeOffset extension to format as relative string

Add a new extension method to DateTime and DateTimeOffset that returns a string representation of the date as a relative string.

For example, DateTime.Today.ToRelativeDateString() should return Today, 12:00 AM, DateTime.Today.AddDays(-1).ToRelativeDateString() should return Yesterday and so on.

Drop support for CsvReader

While CsvReader had a good run, it makes more sense to use a dedicated CSV parser that is up to date. We're dropping the CsvReader, and all it's associated classes, in favor of using something like CsvHelper or TinyCsvParser

Existing query string parameters should be preserved.

When adding query string parameters to a UriBuilder's QueryParameters dictionary, any existing parameters should be preserved.

The QueryStringParametersDictionary should gain an additional constructor which allows an existing query string to be passed in. The Query property should also be settable.

Add HasCustomAttribute extension

Add an extension method HasCustomAttribute to Cadru.Core\Extensions\TypeExtensions which simplifies testing a type to test if it contains a custom attribute.

ExcelDataReader throwing a NullReferenceException

When the ExcelDataReader tries to access a field that is a nullable DateTime field and the original value comes in as an empty string, the parsing fails and throws a NullReferenceException rather than returning a null value.

Refactor Cadru.AspNetCore namespaces

The namespaces in Cadru.AspNetCore still refer to it as Cadru.AspNet and need to be refactored to more closely match the Microsoft.AspNetCore namespaces.

Add methods to Enum(T) and EnumExtensions to get a description.

Enum should have methods to retrieve the value of an EnumDescription attribute applied to an Enum member. It should also have a method which returns a collection of descriptions.

Similarly, the GetDescription method in EnumExtensions should be updated to behave in a similar manner as the one in Enum.

Add a strongly typed Enum helper class.

The standard Enum class in the framework provides a strongly typed TryParse method but not a strongly typed Parse method. Add a strongly typed Enum<T> class which provides a strongly typed Parse method and pass-through methods for the other methods of Enum (and strongly type those that can be).

Expand literals used by TryParseAsBoolean

The BoleanExtensions.TryParseAsBoolean extension method currently only supports the following literals:

  • False - false, f, no, n
  • True - true, t, yes, y

The literals should be expanded to:

  • False - false, f, no, n, 0, na, n/a
  • True - true, t, yes, y, 1

Add additional overloads for LeftSubstring and RightSubstring

The LeftSubstring and RightSubstring methods should have additional overloads for extracting a substring indexed by char that allows the indexing character value to be excluded or included. The default should be that the character is included.

Add addtional string extensions

The additional string extension methods need to be added:

  • bool EndsWithAny(this string source, IEnumerable<string> values)
  • bool EndsWithAny(this string source, IEnumerable<string> values, StringComparison comparisonType)
  • bool EqualsAny(this string source, IEnumerable<string> values)
  • bool EqualsAny(this string source, IEnumerable<string> values, StringComparison comparisonType)
  • bool StartsWithAny(this string source, IEnumerable<string> values)
  • bool StartsWithAny(this string source, IEnumerable<string> values, StringComparison comparisonType)

Create an IEqualityComparer{T} from a lambda

Some LINQ expressions, like Distinct don't accept lambdas but rather expect an instance of an IEqualityComparer<T>. It would be nice to provide a class that can encapsulate creating an IEqualityComparer<T> that uses a key selector function that can be passed in line to those LINQ expressions which expect one.

Cadru.Data.Tests failing

The unit test in Cadru.Data.Tests is failing because it relies on a local file. Need to figure out how to do this through AppVeyor.

Add an easy way to retrieve localized strings.

Localization attributes, such as DisplayAttribute provide an easy mechanism to retrieve a localized value, but DisplayAttribute is sealed and the LocalizableString class is internal. Provide something similar to LocalizableString so other attributes can be made localization aware easily.

Add HttpMessage serializers

Useful for debugging and logging purposes, add Json serializers for HttpResponseMessage and HttpRequestMessage.

CountryCodes enum needs display attributes

The CountryCodes enum in Cadru.Core needs Display, EnumDescription, and UIHint attributes. This requires updating the projects to support .NET Standard 1.1 as the minimum.

AppVeyor builds failing

The AppVeyor builds are failing because it's not targeting C#6. The .sln file has # Visual Studio 14 header (not # Visual Studio 2013); otherwise AppVeyor will force MSBuild 12.0.

Support more fluent unit test assertions

Update Cadru.UnitTest.Framework to support using more fluent extension methods on the standard MS Test Assert (and related) classes. This will keep unit testing code more consistent, so you don't have to know when to use a Cadru specific class (like ConditionAssert) to write code like

var int i1 = 5;
var int i2 = 4;
ConditionAssert.Greater(i1, i2);

Instead, just include the Cadru.UnitTest.Framework namespace and you can write it as

var int i1 = 5;
var int i2 = 4;
Assert.That.Greater(i1, i2);

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.