Skip to content

mhlabs/MhLabs.Extensions

Repository files navigation

MhLabs.Extensions

Collection of extension / helper methods System types.

StringExtensions.cs

string.ToUri() creates a Uri from string.

Throws UriFormatException

Example:

var uri = "https://api.mathem.io/api".ToUri();

string.To<T>() creates an object T from json string.

Throws JsonReaderException

Example:

var order = jsonString.To<Order>();

string.Truncate(maxLength) truncates a string to its max length

Throws ArgumentOutOfRangeException

Example:

var newString = oldString.Truncate(10);


## OrderExtensions.cs
```object.ToJson()```
creates an object T from json string.

Example:

var order = new Order { ... } var json = order.ToJson();


## Env.cs
```Env.Get(key)```
Short hand for Environment.GetEnvironmentVariable(key);

Example:

var apiUrl = Env.Get(ApiBaseUrl);



## CollectionExtension.cs
```IEnumerable.IsNullOrEmpty()```
returns true if collection is null or empty

```IEnumerable.GetChunks(chunkSize)```
returns a IEnumerable of IEnumerable chunks

## Pushing a new version
Set the `Version` number in the <a href="https://github.com/mhlabs/MhLabs.Extensions/blob/master/MhLabs.Extensions/MhLabs.Extensions.csproj"> .csproj-file</a> before pushing. If an existing version is pushed the <a href="https://github.com/mhlabs/MhLabs.Extensions/actions">build will fail</a>.

## Publish pre-release packages on branches to allow us to test the package without merging to master
1. Create a new branch
2. Update `Version` number and add `-beta` postfix (can have .1, .2 etc. at the end)
3. Make any required changes updating the version as you go
4. Test beta package in solution that uses package
5. Create PR and get it reviewed
6. Check if there are any changes on the branch you're merging into. If there are you need to rebase those changes into yours and check that it still builds
7. As the final thing before merging update version number and remove post fix

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages