BoxesNLines.IKnowBetter 0.0.5

dotnet add package BoxesNLines.IKnowBetter --version 0.0.5
                    
NuGet\Install-Package BoxesNLines.IKnowBetter -Version 0.0.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BoxesNLines.IKnowBetter" Version="0.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BoxesNLines.IKnowBetter" Version="0.0.5" />
                    
Directory.Packages.props
<PackageReference Include="BoxesNLines.IKnowBetter" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BoxesNLines.IKnowBetter --version 0.0.5
                    
#r "nuget: BoxesNLines.IKnowBetter, 0.0.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BoxesNLines.IKnowBetter@0.0.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BoxesNLines.IKnowBetter&version=0.0.5
                    
Install as a Cake Addin
#tool nuget:?package=BoxesNLines.IKnowBetter&version=0.0.5
                    
Install as a Cake Tool

iknowbetter

Code libraries often contain types that are private or sealed that you would really like to instantiate or extend regardless.

You don't have access to the source code so you can't modify the protection levels directly, and you're left with no option other than to create your own implementation of the classes you want.

IKnowBetter provides a solution in these cases - it lets you declare that you know better than the library's original author and makes classes and fields public and unsealed according to your requirements.

Don't use this unless you actually Know Better

When the library author made a class private or sealed, they made a decision that you shouldn't be able to instantiate or extend them in your own code.

By using IKnowBetter, you are asserting that you know better than the original author, but you shouldn't be surprised if changing the protection levels leads to unexpected results.

Be mindful when using this, and make sure you actually do know better than the original library author!

How to use

  1. Install the BoxesNLines.IKnowBetter NuGet package into your project.

  2. Add a configuration file for IKnowBetter to the root of your project, called IKnowBetter.jsonc.

  3. Populate the configuration file to determine which classes you want to make public, unseal, etc.

Commands available are: UnsealClass, MakeClassPublic, MakeFieldPublic, FullyUnlockClass and FullyUnlockAssembly.

Example configuration:

[
  {
    "IKnowBetter": "UnsealClass", // UnsealClass/MakeClassPublic/MakeMethodPublic/FullyUnlockClass
    "Assembly": "IKnowBetterTestClassLibrary", // Typically the same name as the DLL
    "Class":"IKnowBetterTestClassLibrary.SealedClass" // Use the fully-qualified name of the class
  },
  {
    "IKnowBetter": "MakeClassPublic",
    "Assembly": "IKnowBetterTestClassLibrary",
    "Class":"IKnowBetterTestClassLibrary.PrivateClass"
  },
  {
    "IKnowBetter": "MakeClassPublic",
    "Assembly": "IKnowBetterTestClassLibrary",
    "Class":"IKnowBetterTestClassLibrary.InternalClass" // MakeClassPublic works on internal classes as well as private!
  },
  {
    "IKnowBetter": "MakeMethodPublic",
    "Assembly": "IKnowBetterTestClassLibrary",
    "Class":"IKnowBetterTestClassLibrary.ClassWithPrivateMethod",
    "Member": "GetString"
  },
  {
    "IKnowBetter": "MakeFieldPublic",
    "Assembly": "IKnowBetterTestClassLibrary",
    "Class":"IKnowBetterTestClassLibrary.ClassWithPrivateField",
    "Member": "PrivateString"
  },
  {
    "IKnowBetter": "FulyUnlockAssembly",
    "Assembly": "IKnowBetterTestClassLibrary"
  },
  {
    "IKnowBetter": "FullyUnlockClass",
    "Assembly": "IKnowBetterTestClassLibrary",
    "Class":"IKnowBetterTestClassLibrary.LockedClass"
  },
]
  1. Build your project.

The build logs should show IKnowBetter taking effect during the build. After the build, the classes you specified will be unlocked according to the configuration!

  1. IMPORTANT - Drop caches from your IDE

Your IDE will probably cache the protection levels of the classes modified by IKnowBetter, causing it to continue to show warnings.

The caches should eventually update by themselves, but you probably don't want to wait. To refresh the caches:

  • In Rider: File > Invalidate Caches... > Invalidate and Restart
  • In Visual Studio: Delete the C:\Users\<you>\AppData\Local\Microsoft\VisualStudio\<version>\ComponentModelCache folder

Seriously, drop your IDE's caches

Just in case you missed it, you need to drop your IDE's caches after you run IKnowBetter. Otherwise the IDE will likely continue to complain that you are accessing private members.

After your caches refresh, your IDE will stop complaining.

Warnings

If you Know Better you probably shouldn't need to be told these things, but here are some warnings and disclaimers:

  • Running dotnet restore --force will retrieve a fresh copy of your referenced packages, reversing any changes made by IKnowBetter
  • You can remove IKnowBetter by simply removing the package reference from your project, but the changes it made will persist until you run dotnet restore --force or otherwise replace the package DLL
  • IKnowBetter tacks some metadata onto the DLL when it modifies it so it won't attempt to modify it multiple times and slow down your builds unnecessarily. You can force IKnowBetter to re-run by performing dotnet restore --force
  • Don't try to modify types from your local source code - only target referenced libraries. IKnowBetter will ignore the contents of your project itself
  • Don't try to modify types from project references - the build will likely fail due to the compiler locking the local project
  • Don't try to modify types from .NET itself or from the Microsoft.Build namespace - the build will likely hang as it will hold locks on these
  • Beware of changes introduced when you update your NuGet packages - the library's author may have changes the structure of the code
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.5 113 4/17/2026
0.0.4 100 4/17/2026
0.0.3 111 3/19/2026
0.0.2 104 3/19/2026
0.0.1 106 3/19/2026