Skip to content

.NET Core tool modifying Roslyn compiler to access internals/privates. In other words, you can access to any internals/privates in other assemblies, without reflection.

License

Notifications You must be signed in to change notification settings

pCYSl5EDgo/Csc-Manager

Repository files navigation

csc-manager

This is a command line tool for the purpose of using the Roslyn compiler that correctly handles IgnoresAccessChecksToAttribute.

Description

About IgnoresAccessChecksToAttribute English Article. Japanese Article.

You can access other assemblies' internal/private members without any restriction.

This tool can

  • enables csc.exe to compile codes that contain internal/private access.
  • disables csc.exe not to compile codes that contain internal/private access.
  • enable-vscodes csc.exe to compile codes that contain internal/private access.
  • disable-vscodes csc.exe not to compile codes that contain internal/private access.

Install

Csc-Manager is distributed as dotnet global tool.

On your terminal, you can install the csc-manager by following command.

dotnet tool install -g Csc-Manager

You can now use csc-manager command.

Required Environment

Above .NET Core 2.1

Usage

enable

This command modifies the existing Microsoft.CodeAnalysis.CSharp.dll in order to enable csc.exe to process IgnoresAccessChecksToAttribute. This saves original data as as a file Microsoft.CodeAnalysis.CSharp.dll.bytes.

Following options are all optional.

  • -directory
  • Directory contains all assemblies which Microsoft.CodeAnalysis.CSharp.dll is dependent on.
  • -path default value => empty string
  • Microsoft.CodeAnalysis.CSharp.dll path.
  • If it is empty, Microsoft.CodeAnalysis.CSharp.dll will be searched in the -directory folder.

Sample Code

csc-manager enable -directory "C:\Program Files\dotnet\sdk\3.1.101\Roslyn\bincore"

disable

This command restores Microsoft.CodeAnalysis.CSharp.dll to its original condition by rename Microsoft.CodeAnalysis.CSharp.dll.bytes Microsoft.CodeAnalysis.CSharp.dll.

Following options are all optional.

  • -directory
  • Directory contains all assemblies which Microsoft.CodeAnalysis.CSharp.dll is dependent on.
  • -path default value => empty string
  • Microsoft.CodeAnalysis.CSharp.dll path.
  • If it is empty, Microsoft.CodeAnalysis.CSharp.dll will be searched in the -directory folder.

Sample Code

csc-manager disable -directory "C:\Program Files\dotnet\sdk\3.1.101\Roslyn\bincore"

enable-vscode

VS Code is a special Editor. When you use IgnoresAccessChecksToAttribute, you have a lot of errors related to internal/private access.

No options are provided.

Sample Code

csc-manager enable-vscode

disable-vscode

This command restores Microsoft.CodeAnalysis.CSharp.dll of OmniSharp to its original condition by rename Microsoft.CodeAnalysis.CSharp.dll.bytes Microsoft.CodeAnalysis.CSharp.dll.

Sample Code

csc-manager disable-vscode

enable-dotnet

Enable your dotnet sdk to access internal/private members.

No options are provided.

Sample Code

csc-manager enable-dotnet

disable-dotnet

This command restores Microsoft.CodeAnalysis.CSharp.dll of dotnet runtimes&sdks to its original condition by rename Microsoft.CodeAnalysis.CSharp.dll.bytes Microsoft.CodeAnalysis.CSharp.dll.

Sample Code

csc-manager disable-dotnet

download

This command downloads Csc compiler from Nuget Package.

Sample Code

mkdir cscDir
csc-manager download cscDir

generate

This command downloads Csc compiler from Nuget Package and enables it.

Sample Code

mkdir cscDir
csc-manager generate cscDir

Hint

Unity

Provide that you use Unity Editor on a windows machine which installed via Unity Hub, you can find the Microsoft.CodeAnalysis.CSharp.dll in C:\Program Files\Unity\Hub\Editor\2020.1.0a14\Editor\Data\Tools\Roslyn. Change the version accoring to your environment.

dotnet core

Provide that you want to enable your dotnet command to handle correctly IgnoresAccessChecksToAttribute, you can find the Microsoft.CodeAnalysis.CSharp.dll in C:\Program Files\dotnet\sdk\3.1.100\Roslyn\bincore. Change the version accoring to your environment.

LICENSE

MIT

Special Thanks

Thank you @mob-sakai! With your work, Japanese articles and discussion you and me, I developed this!

About

.NET Core tool modifying Roslyn compiler to access internals/privates. In other words, you can access to any internals/privates in other assemblies, without reflection.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages