Category: FileExtension

FileExtension–PostMortem- part 7

It was interesting to wrote this project.  At the final, it features an web site ( ) and a NuGet package ( ). Also , I have learned how to start Windows Terminal to start Angular / .NET Core / Tests

wt new-tab -p “Windows PowerShell” -d . cmd /k “cd src && dotnet build && cd RecognizeFileExtWebAPI && dotnet watch run”  ;split-pane -p “Windows PowerShell” -d . cmd /k “cd src && dotnet build && cd TestFileExtensions && dotnet watch test” ;  split-pane -p “Windows PowerShell” -d . cmd /k “cd src && cd FileExtensionAng && npm i && ng serve -o”

and refreshed my GitHub actions knowledge ( I am very fond of CI – and , if I can, CD )

Also, I have now a better understanding of a csproj file in relation with nuget :

   <None Remove=”plugins\FileExtension.targets” />
<Content Include=”plugins\FileExtension.targets”>

   <Content Include=”plugins\**\*.dll”>

It was refreshing to know that, even I like the Skinny Controllers concept, however the WebAPI is not so light .

Hopefully someone will find the package useful – or at least the site

FileExtension–part 6 – CI/CD

So now how to make visible all those coding ?

For tests –CodeCov, hosts for free to see the coverage

For documentation – ReadTheDocs, hosts for free.

For packaging  – NuGEt

For more detailed analysis Sonar can show code smells and bugs and more

GitHub actions allows me to run all those automatically and gather results

For showing a website – Azure  – can show the usage.

I was thinking that it is enough for the people to understand the application

FileExtension–Tests–part 5

The tests are the easy part. I have put some files on a folder( ) and test if the extension matches the recognizer.

As NuGet packages I used




FluentAssertion allows me to write more readable tests , like 


LightBDD allows me to write tests in a more “business “ way :

await Runner
     .AddAsyncSteps(_ => When_Read_The_File(fileName))
         _ => Then_Should_Recognize_File(fileName),
         _ => Then_The_Extension_Matches(fileName)

You can see the result at = go down to see the Given / When /

Also, for enumerating files from the folder to test, I use ClassData

public async void TestMultipleFiles(string nameFile)

FileExtension – GUI–part 4

Now I must do something for the people that just want to use the software. The most usual , for me, it is a .NET Core WebAPI site ( with swagger ) and an Angular frontend.

You can find the sources at . Some thoughts:

For .NET Core ( see ) I use the following NuGET packages ( other than usual .NET Core)








The final result can be seen at

For Angular( I use the following packages( other than usual Angular)



The final result can be seen at

FileExtension–plugins–part 3

What I have more in mind is that the people can add easy their code for extensions.

That means:

  1. Have an easy class to add the magic number in the header for an extension
  2. Have other people add their own implementations, not just the header
  3. Have an easy way to add the project with their code


First item it is easy – just create a class RecognizeFirstBytes and pass into constructor the first bytes

As an example , see the sln implementation

    public class RecognizeSln : RecognizeFirstBytes
        public RecognizeSln() : base("EFBBBF0D0A4D6963726F736F66742056697375616C2053747564696F20536F6C7574696F6E2046696C65")
            Extension = new string[1] { "sln" };

The second item can be implemented with an interface IRecognize

    public interface IRecognize: IEquatable<IRecognize>
        Result InfoNeeded(byte[] b=null);
        string[] Extension { get; set; }

The third item can be made by  making a third project  that  either references all other projects, either loading others as plugins . Because of the experience, I choose the most interesting one – plugins. I need first . Second I need the plugins to be copied – I use a Target

  <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
    <Exec Command="xcopy &quot;$(ProjectDir)../plugins/*.dll&quot; &quot;$(ProjectDir)plugins&quot; /E /F /I /Y /R" />

And last I need this plugin loader , when packed as nuget  at , to have also the plugins – for this I use the csproj

  <Content Include="plugins\**\*.dll">

FileExtension– export data from CSV–part 2

First, is how to export data from table ( into classes . First, the table must be transformed into a more programmatic recognizable way – like a CSV  – see

Then a solution is to have into the dll ( as embedded resource or as a file) . The second solution, more complicated , is to use Roslyn Source Code Generators to generate the classes for each element of the CSV .

I’d liked more the second solution – the sources are at 

What it generates is like this

namespace RecognizeCustomSigs_GCK {
    class RecognizeFromGCKLine0_JP2: RecognizeFromLineCustomsigs{
        public RecognizeFromGCKLine0_JP2(): base("JPEG2000 image files,00 00 00 0C 6A 50 20 20,JP2")                

FileExtension–idea- part 1

Every now and then we accept file uploads ( to a site  ) – or we have files in outlook that we want to open – but we do not know if the extension matches the content of the file.

There are numerous way to do it , however , I have been attracted by Magic Numbers – a header into the file that says what is the kind of the file.

For example, a .sln file has always those characters inside:

Microsoft Visual Studio Solution File, Format Version

You can then recognize if it is a real sln if it contains those characters.

Reading more on the internet, I have found

Now, there are multiple programs and sites to do this magic number verifier – however, in order to practice programming, is always a good idea to start somewhere – so let’s see where it goes.

You can find the sources at

The application is live at

You can find a NuGet package at

Andrei Ignat weekly software news(mostly .NET)

* indicates required

Please select all the ways you would like to hear from me:

You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.