Giter Club home page Giter Club logo

nameless's Introduction

Nameless

This repository contains all code that I assume is useful in most of the cases where I need to build something. So, if you think that it could be useful for you, feel free to fork, clone, etc. Also, I tried to mention every person that I got something from. If you find code that needs to be given the correct authorship, please, let me know.

Starting

Instructions below will show your the way to get things working.

Pre-requirements

You'll need to install, at least, .NET Core SDK and Visual Studio Code. Just follow the links:

Development

Here are a couple of apps that I find useful when developing:

  • LINQPad: For writing LINQ-Queries or use as a REPL.
  • Notepad++: You know what this is, don't you?
  • SQLite Browser: One of the best data browsers for SQLite databases.
  • Git: No need (I hope) for presentations.
  • ILSpy: When you want to take a peek on the compiled code that no one have the source.
  • SMTP4Dev: Small SMTP server that runs as a service on your machine, for send e-mail tests. Very useful.
  • DBeaver: An alternative for databases management. Don't have all options for each specific database, but, Oh-boy, it's useful.
  • Postman: Useful to test Rest API calls. Similar to SoapUI, but I think that it's much more easy to handle.
  • Sonarlint: Analyze and suggest code modifications on-the-fly. Has a free-tier.

These are all just suggestions.

Testing

Maybe you'll need to install the coverage tool and report tool. If I'm not mistaken, Visual Studio already has those dependencies installed for you after restore. But...

.NET Coverlet Tool

dotnet tool install -g coverlet.console

.NET Report Generator Tool

dotnet tool install -g dotnet-reportgenerator-globaltool

Skipping Tests

Some tests will need a software to run or any other resource that may not be available on your build environment. For example, ProducerConsumer for RabbitMQ project needs RabbitMQ to run.

For these tests to run on my GitHub Actions (workflow) I needed a way to "mute" them and run only locally, since I could setup, again, RabbitMQ on a Docker container on my machine.

So, if you need to "mute" a test and run it only locally, use the RunsOnDevMachineAttribute attribute on your test method.

Creating Code Coverage Report

When you feel comfortable, you should run all tests and output the coverage result to a folder. The Report Generator Tool will take from there. So, do as follow:

Run tests with:

dotnet test --logger:"Html;LogFileName=code-coverage-log.html" --collect:"XPlat Code Coverage" --results-directory ./code-coverage/ --verbosity normal

Run the report tool with:

reportgenerator "-reports:./code-coverage/**/coverage.cobertura.xml" "-targetdir:./code-coverage/report" -reporttypes:Html

If you want to know more about the report tool, see their FAQ.

Coding Styles

Nothing written into stone, use your ol'good common sense. But you can refere to this page, if you like: Common C# Coding Conventions.

Some Ideas to Keep in Mind

  • When I create a new extension method I never check for nullability of the target instance. If the target instance is null, you'll get an NullReferenceException on your face, punk!
  • default vs null :
    • Am I sure is a reference type? null
    • Am I sure is a value type? default
    • I'm not sure at all: default
  • I think that most of my developer's life I spent writing C# code. But I like that kind of code organization from Java. So, I use, almost, the same code style identation on my projects.
  • Methods that returns arrays, collections or enumerables in general, DO NOT RETURN NULL VALUE EVER!!! If there's no value to return, just return an empty enumerable from the same type. Use Array.Empty<T>() or Enumerable.Empty<T>(), or I'll cut the tips of your fingers with a rust scissor...thanks.
    • If you're returning an IEnumerable<T>, probably you should use the yield keywork on your method return directive.

Dependency Injection "Battle"

Let us not talk about Unity or MEF. These were from a really long time ago, on a far-far away galaxy...(I think that MEF is still in use inside some modern projects from Microsoft).

Look, I, really, understand that Microsoft has its own modern dependency injection system (ServiceCollection extensions). It'll work for most of all simple cases and applications. But for more complex scenarios, some that I cross paths on my developer's life, it'll not be the best.

Don't get me wrong, it's simple, fast, reliable and easy to use. And should be your first choice if you're starting a new ASP.NET Core project.

But I'll advocate for Autofac. It has way more road beneath its codebase and has some amazing features. Like Decorators and Type Interceptors. So, that said, all projects inside this repository will favor Autofac. ๐Ÿค˜๐Ÿ˜œ

Deployment

I'm using GitHub Actions to act as a CI/CD. All files are located in the .github folder.

Template

There is a small "microservice" template inside the template folder. To install it just use:

dotnet new install <FULL_PATH_TO_MICROSERVICE_FOLDER>

E.g:

dotnet new install C:\Workspace\Nameless\template\Microservice\Nameless.Microservice

After that you can create a new project, using dotnet new or Visual Studio / New Project and search for Microservice template.

Contribuition

Just me, at the moment.

Versioning

Using SemVer for assembly versioning.

Authors

  • Marco Teixeira (marcoaoteixeira) - initial work

License

MIT

Acknowledgement

  • Hat tip to anyone whose code was used.

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.