Giter Site home page Giter Site logo

icarus-consulting / yaapii.atoms Goto Github PK

View Code? Open in Web Editor NEW
43.0 4.0 2.0 2.28 MB

Object-Oriented .Net primitives. A port of cactoos library by Yegor Bugayenko, author of the "Elegant Objects" books.

License: MIT License

C# 99.61% PowerShell 0.39%
yaapii atoms cactoos encapsulate-objects elegantobjects primitives

yaapii.atoms's People

Contributors

adyic avatar avexcaesar avatar dfu398 avatar edjopato avatar herickj-22 avatar icacle avatar icaobu avatar jaanpeeter avatar jussen avatar koeeenig avatar leonardkrml avatar luplayer avatar lwulok avatar meerownymous avatar mse1188 avatar orwel avatar pz1337 avatar timmeeyyy avatar vernou 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

Watchers

 avatar  avatar  avatar  avatar

yaapii.atoms's Issues

List: Contains<T> : IScalar<bool>

We need a contains Enumerable.

It should implement IScalar and be able to test if a given item is in the list.
It should also work by applying a function to test an item.

Bug & missing Tests: Primitives DoubleOf seems to round!

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • [] feature request

Expected Behavior

Accuracy of the number as double is the same like the accuracy of the number as string
An test is existing.

Actual Behavior

DoubleOf() rounds the value
No Test exists

Steps to reproduce the behavior

DoubleOf(Math.Pi.ToString()) == Math.Pi;

The log given by the failure.

Mention any other details that might be useful

Extend Mapped class, getting index and value like Linq Select

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

With linq select it is posible to get the Index and value of current element in List.
It would be nice to have in Mapped-Class.

Actual Behavior

Getting index and value of Mapped not posible!?

Steps to reproduce the behavior

The log given by the failure.

Mention any other details that might be useful

lst.Select((tValue, tIndex)=> new { Value=tValue, Index=tIndex});

Class for Linq 'Any'

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

A Atoms class is needed to replace Linq 'Any' method.

Actual Behavior

No Atoms class exists, using Linq instead.

Steps to reproduce the behavior

The log given by the failure.

Mention any other details that might be useful

add new ctor for contains, which takes a function and a bool (Contains for all => Default:false)

ICallable: NotNull

We need a class NotNull : ICallable. It must not accept when null is the output and raise an exception.
The exception message must be possible to inject into ctor.
The exception itself must be possible to inject into ctor.

refactor: rename ICallable and IProc interfaces

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

Interfaces whose purpose is to wrap C# classes Func and Action are named IFunc and IAction.
Methods are called Invoke.

Actual Behavior

IFunc is called ICallable and IAction is called IProc. Methods are callled Call() and Run().

Steps to reproduce the behavior

The log given by the failure.

Mention any other details that might be useful

Replacement for Linq ForEach()

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

We have a class which accepts a IEnumerable and can execute a function for each element.

Origin: @ICACLE wanted to do: collection.ToList().ForEach(). We need a convenient and intuitive way to do it in OOP world.

Actual Behavior

Steps to reproduce the behavior

The log given by the failure.

Mention any other details that might be useful

Lets discuss fist, how it should be called or if an existing class can be extended to accomplish it.
When discussion is finished, remove the question label.

Primitives: CharOf

We need a Scalar "CharOf" which accepts multiple other types and returns a Char as value.

Generic Fork

We need a generic fork which represents a switch case construct

Add MIT-License where necessary

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

all yaapii classes have a MIT-license as header

Actual Behavior

not all yaapii classes have a MIT-license as header

Steps to reproduce the behavior

The log given by the failure.

Mention any other details that might be useful

Create Each class which takes Action<T> and IEnumerable<T>

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

And has a ctor accepting Action<> (C# Lambda) and IEnumerable<>. It is for executing the Action for all elements in the IEnumerable<>, its input is an element from the list.
We need a new class replacing Foreach() of LinQ
Action ctors has to be deleated out of And class

Actual Behavior

Ctor is not there :(
No Class exists, but some ctors exist in and

Steps to reproduce the behavior

The log given by the failure.

Mention any other details that might be useful

see #56
see #40

And: Split to Generic and non Generic Version

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

And like in the examples does not need generic parameter.
Expected two classes: One which needs no generic and another that needs generic parameter.

Actual Behavior

And needs generic parameter in every ctor.

Steps to reproduce the behavior

The log given by the failure.

Mention any other details that might be useful

And = List.All in Linq
see #56
see #36

Joined: ctor to accept IEnumerable and params item

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

We can make a Joined and inject a source and params T[] to be joined.

Actual Behavior

Steps to reproduce the behavior

The log given by the failure.

Mention any other details that might be useful

Missing ctor for TextOf(double)

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

I can make a Text of a double

Actual Behavior

No possiblity to call 'new TextOf(Math.Pi)'

Steps to reproduce the behavior

The log given by the failure.

Mention any other details that might be useful

To convert a double to a String it should be used '.ToString("G17")'. Not losing accuracy.

Replacement for LinQ All

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

A Atoms class is needed to replace Linq 'Any' and 'All' method.

Actual Behavior

No Atoms class exists, using Linq instead.

Steps to reproduce the behavior

The log given by the failure.

Mention any other details that might be useful

Perhaps And class can be extended to offer the requested behaviour.
see #40
see #36

IScalar: NotNull

we need a NotNull Scalar.
It should throw an ArgumentNullException, if asked for a value and its value is null.
It should accept a custom string as message to put in the Exception.

Docs: Docs not visible when using classes from Atoms nuget package

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

Development IDE shows XMLDOC when using the library.

Actual Behavior

No Docs are shown.

Steps to reproduce the behavior

instanciate a class: new FormattedText( and navigate through constructors. Nothing there.

The log given by the failure.

Mention any other details that might be useful

<DocumentationFile>bin\Release\net45\blabla.xml</DocumentationFile>

This should be included in the csproj file. Also, Xml Doc creation must be activated for the project.

Read file content with whitespaces in Uri

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

Read file content from where the path to the file is provided with a Uri.

Actual Behavior

Reading file content fails if the Uri contains whitespaces in path

Steps to reproduce the behavior

[Fact]
public void ReadsSimpleFileContentWithWhitespacesInUri()
{
   var dir = "artifacts/Input StreamOf Test"; var file = "txt-1"; var path = Path.GetFullPath(Path.Combine(dir, file));
   Directory.CreateDirectory(dir);
   if (File.Exists(path)) File.Delete(path);

   String content = "Hello, товарищ!";
   File.WriteAllBytes(path, new BytesOf(new TextOf(content, Encoding.UTF8)).AsBytes());

   Assert.True(
         new TextOf(
             new InputAsBytes(
                 new InputOf(
                      new InputStreamOf(
                           new Uri(path))))
          ).AsString() == content,
          "Can't read file content");
}

The log given by the failure.

Message: System.IO.DirectoryNotFoundException : Could not find a part of the path 'D:\Daten\GITHUB\Yaapii.Atoms\tests\Yaapii.Atoms.Tests\bin\Debug\netcoreapp1.1\artifacts\Input%20StreamOf%20Test\txt-1'.

Mention any other details that might be useful

ICallable: CallableWithFallback

We need a callable that accepts a fallback function and value.
The function can be invoked to retrieve a fallback value.
The value can also be injected directly.

NonGeneric Enumerables

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

This works:

var list = new ArrayList(); //IEnumerable, NOT IEnumerable<T>!
new LengthOf(list).Value()

Actual Behavior

I have to do:

new LengthOf<string>(new List<string()); 

Generic Parameter is a must.

There are more classes in which sometimes it is not necessary to give a generic parameter.
For example, And. There is an And ctor which accepts Actions. Actions do not need a generic parameter. So And should be split into more classes. There are some more classes like this.
These should be split up, for example.

Steps to reproduce the behavior

The log given by the failure.

Mention any other details that might be useful

Add class ScalarWithFallback

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

We have a Scalar which delivers a fallback value if fails.

Actual Behavior

Steps to reproduce the behavior

The log given by the failure.

Mention any other details that might be useful

Style: ctors of classes should follow a consistent argument order

We need a consistent argument order in constructors of objects.

Example:
Filtered accepts a list and a filter function. Sometimes the function is the first argument, sometimes the last. This has to change.

Since all arguments using params keyword need to appear last, I think all lists have to go last and functions have to go first.

Extend StickyScalar by reload condition

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

I can force a reload by method or can give a reload condition (function) to Ctor

Actual Behavior

No reload posibility

Steps to reproduce the behavior

The log given by the failure.

Mention any other details that might be useful

I think reload condition is more OOP, right?

Dispose Methode of OutputTo and AppendTo can produce Exception

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

Dispose will close stream, independent of used ctor.

Actual Behavior

I think, the stream will not be closed by dispose methode, when getting stream by function...
Edit:
I wrote a test for it:
The Dispose-Methode will not only not close the given Stream, it produces a exception, because it will create another strem on a blocked item.

Steps to reproduce the behavior

The log given by the failure.

Mention any other details that might be useful

Net461 projects Thread issue

Atoms are NetStandard. They reference NetStandard Nuget package System.Threading.Thread.
This package can't be loaded by Net461 projects. It should be removed/replaced.

IScalar: ScalarWithFallback

We need a scalar that accepts a fallback function and value.
The function can be invoked to retrieve a fallback value.
The value can also be injected directly.

List: Previous and Next

We need classes for getting the Previous() or the Next() Item in an enumerable.
They could be a Scalar and accept a Collection and an Item.
They need to serve a fallback if no item is present.

No String Contains found (with IgnoreCase)

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

A class wich takes two strings and a bool (optional): inputValue, containingValue, ignoreCase
Returns true if 'inputValue' contains 'containingValue'.
Ignore case switch.

Actual Behavior

Does not exist

Steps to reproduce the behavior

The log given by the failure.

Mention any other details that might be useful

Replaces CLEs Extension method:
public static bool Contains(this string value, StringComparison strComparison)

Let ItemAt's fallback function give the exception

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

ItemAt accepts a BiFunc fallback function, where the occured Exception is the first function parameter.

Actual Behavior

ItemAt accepts only a IFunc<IEnumerable<T>,T>
ItemAt throws NoSuchElementException, this is not true for every case.
For example, if the inserted IEnumerable and its IEnumerator does not support Reset(), there is a NoSuchElementException. This is not correct.

The fallback function in ItemAt<T> and in ItemAtEnumerator should be a BiFunc<Exception, IEnumerable<T>, T>

Steps to reproduce the behavior

The log given by the failure.

Mention any other details that might be useful

OutputTo: Append

OutputTo cannot append to existing data. We need a solution for appending.
Appending mechanism must be available through all ctors that can point to existing data, like OutputTo(string path).

docs: Change author to ICARUS Consulting GmbH

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

ICARUS is the author

Actual Behavior

Miro Tunk is the Author

Steps to reproduce the behavior

The log given by the failure.

Mention any other details that might be useful

ThreadBoundFunc

We need a function that can be bound to a thread.
The thread should be injected.
Also, it has to be possible to inject just the thread id.

Fails should accept a specific Exception in ctor

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

We can inject a specific Exception into a ctor of a fail so that it gets thrown.

Actual Behavior

We cannot inject specific Exceptions into ctor

Steps to reproduce the behavior

The log given by the failure.

Mention any other details that might be useful

ItemAt<T> throws NullReferenceException

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

ItemAt throws a specific Exception

Actual Behavior

it throws a NullReferenceException

Steps to reproduce the behavior

new ItemAt<string>(
   new List<string>()
).Value();

The log given by the failure.

Mention any other details that might be useful

Ternary does not work as expected

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Expected Behavior

Ternary delivers third argument if condition is false

Actual Behavior

Ternary tries to deliver from second argument

Steps to reproduce the behavior

          var stack = new Stack<string>();
          var eql = new Ternary<bool, bool>(
                stack.Count > 0,
                new ItemAt<string>(
                        new List<string>(stack)
                    ).Value() == cmd,
                false
                ).Value();

The log given by the failure.

Mention any other details that might be useful

Remove unchecked classes

We can remove IoChecked and IoUnchecked classes.
These classes have been ported, but are irrelevant in .Net: In java, exception throwing has two faces: Checked or Unchecked. In .Net, this is not true.

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.