Autor: Thomas Ley

  • SonarQube Code Duplicates

    Sometimes you need to copy code between different projects for several reasons. It is required that the same class has to be in both projects e.g. a class that is compiled with different frameworks. But this has a negative impact on code analysis results regarding code duplicates. So let’s take an analysis result of a…

  • Dynamically create a generic using reflection

    A long time ago I created a class which helps create a sut for unit testing. This class is generic and has the type of the sut as a generic parameter. Details see ContextFor<> zum Testen des SUT. Now, I was trying to use the `ContextFor<T>` in a data-driven test which passes the type as…

  • Lazy loading of assemblies can be tricky

    NUnit error message on data-driven test: `Test` is Inconclusive ReSharper Test Runner warning: Element `Test` was left pending after its run completion. Recently I was doing some testing and trying to check if all classes have a corresponding test class. Therefore I used data-driven NUnit tests, which uses a list of all classes in non-test…

  • Powershell 7 and „Trusted Publishers“

    Untrusted Publishers Recently, I installed `Powershell 7` and was using it for a while. After settings my code security to AllSigned, I got the following error. File C:\…\PSReadLine.format.ps1xml is published by CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US and is not trusted on your system. Only run scripts from trusted publishers. This is a little…

  • ModeDetector vs. Precompiler Directives

    Disclaimer: This solution does not apply to multi-framework targeting. The problem Regularly, I do a lot of refactoring, which means renaming classes and methods. Tools help a lot to rename dependencies and all dependent code. But sometimes, tools cannot determine the correct refactoring for commented-out code. But why care about commented-out code? Because code, which…

  • ContextFor<> zum Testen des SUT

    In meinen Projekte der letzten Jahren ist mit der Zeit eine Hilfsklasse fürs Testen entstanden. Das Problem war das Erstellen des SUT mittels Konstruktor, welcher bei Dependency Injection entsprechend viele Paramter hat oder haben kann. Hier ein Beispiel mit „nur“ 5 Konstruktor Parameter. Dadurch ist Builder entstanden, welcher für jeden Konstruktor Parameter des SUT ein…

  • Dictionary ohne KeyNotFound-Exception

    Derzeit arbeite ich mit dem DevExpress DataGrid für WPF und erstelle die Spalten dynamisch, auf der Basis des Datenbankmappings. Dabei greifen die Daten auf normale Properties, aber auch Felder in einem Dictionary zu. Problem: Nicht jedes Feld aus dem Mapping z.B. „title“ hat auch in dem Dictionary einen entsprechenden Schlüssel. Das DataGrid, bzw. das Binding…

  • Comic – The Story Of DI

    Comic – The Story Of DI

    Für einen Vortrag über Dependency Injection ist eine kleines Comic entstanden. Der Vortrag ist eine Einführung in Dependency Injection, Interfaces, Injection Types und Lifetime Scopes. Er dient als Vorbereitung für eine Einführung und Vertiefung in Autofac, dem vielleicht nächsten Comic Strip, hier beim Code Quality Coach. Das Comic findest du auf GitHub – The Story…

  • Refactoring I – Die Endlosschleife

    Refactoring I – Die Endlosschleife

    Das Refactoring von Code ist laut Wikipedia eine Umstrukturierung von Codes ohne eine funktionale Veränderungen der Software aus Anwendersicht. Es werden nicht-funktionale Anforderungen wie Wartbarkeit, Lesbarkeit, Erweiterbarkeit und weitere *-keiten verbessert. Refactoring kann beispielsweise durch Implementierung eines Plugin Mechanismus stattfinden. Das System wird aber im Rahmen des Refactorings nicht erweitert, sondern allenfalls bestehende Komponenten auf…