mirror of https://github.com/icsharpcode/ILSpy.git
15 changed files with 292 additions and 167 deletions
@ -0,0 +1,123 @@ |
|||||||
|
using System; |
||||||
|
|
||||||
|
using FluentAssertions; |
||||||
|
|
||||||
|
using NUnit.Framework; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy.Tests |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class CommandLineArgumentsTests |
||||||
|
{ |
||||||
|
[Test] |
||||||
|
public void VerifyEmptyArgumentsArray() |
||||||
|
{ |
||||||
|
var cmdLineArgs = new CommandLineArguments(new string[] { }); |
||||||
|
|
||||||
|
cmdLineArgs.AssembliesToLoad.Should().BeEmpty(); |
||||||
|
cmdLineArgs.SingleInstance.Should().BeNull(); |
||||||
|
cmdLineArgs.NavigateTo.Should().BeNull(); |
||||||
|
cmdLineArgs.Search.Should().BeNull(); |
||||||
|
cmdLineArgs.Language.Should().BeNull(); |
||||||
|
cmdLineArgs.NoActivate.Should().BeFalse(); |
||||||
|
cmdLineArgs.ConfigFile.Should().BeNull(); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void VerifyHelpOption() |
||||||
|
{ |
||||||
|
var cmdLineArgs = new CommandLineArguments(new string[] { "--help" }); |
||||||
|
cmdLineArgs.ArgumentsParser.IsShowingInformation.Should().BeTrue(); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void VerifyForceNewInstanceOption() |
||||||
|
{ |
||||||
|
var cmdLineArgs = new CommandLineArguments(new string[] { "--newinstance" }); |
||||||
|
cmdLineArgs.SingleInstance.Should().BeFalse(); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void VerifyNavigateToOption() |
||||||
|
{ |
||||||
|
const string navigateTo = "MyNamespace.MyClass"; |
||||||
|
var cmdLineArgs = new CommandLineArguments(new string[] { "--navigateto", navigateTo }); |
||||||
|
cmdLineArgs.NavigateTo.Should().BeEquivalentTo(navigateTo); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void VerifyNavigateToOption_NoneTest_Matching_VSAddin() |
||||||
|
{ |
||||||
|
var cmdLineArgs = new CommandLineArguments(new string[] { "--navigateto:none" }); |
||||||
|
cmdLineArgs.NavigateTo.Should().BeEquivalentTo("none"); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void VerifyCaseSensitivityOfOptionsDoesntThrow() |
||||||
|
{ |
||||||
|
var cmdLineArgs = new CommandLineArguments(new string[] { "--navigateTo:none" }); |
||||||
|
|
||||||
|
cmdLineArgs.ArgumentsParser.RemainingArguments.Should().HaveCount(1); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void VerifySearchOption() |
||||||
|
{ |
||||||
|
const string searchWord = "TestContainers"; |
||||||
|
var cmdLineArgs = new CommandLineArguments(new string[] { "--search", searchWord }); |
||||||
|
cmdLineArgs.Search.Should().BeEquivalentTo(searchWord); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void VerifyLanguageOption() |
||||||
|
{ |
||||||
|
const string language = "csharp"; |
||||||
|
var cmdLineArgs = new CommandLineArguments(new string[] { "--language", language }); |
||||||
|
cmdLineArgs.Language.Should().BeEquivalentTo(language); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void VerifyConfigOption() |
||||||
|
{ |
||||||
|
const string configFile = "myilspyoptions.xml"; |
||||||
|
var cmdLineArgs = new CommandLineArguments(new string[] { "--config", configFile }); |
||||||
|
cmdLineArgs.ConfigFile.Should().BeEquivalentTo(configFile); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void VerifyNoActivateOption() |
||||||
|
{ |
||||||
|
var cmdLineArgs = new CommandLineArguments(new string[] { "--noactivate" }); |
||||||
|
cmdLineArgs.NoActivate.Should().BeTrue(); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void MultipleAssembliesAsArguments() |
||||||
|
{ |
||||||
|
var cmdLineArgs = new CommandLineArguments(new string[] { "assembly1", "assembly2", "assembly3" }); |
||||||
|
cmdLineArgs.AssembliesToLoad.Should().HaveCount(3); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void PassAtFileArguments() |
||||||
|
{ |
||||||
|
string filepath = System.IO.Path.GetTempFileName(); |
||||||
|
|
||||||
|
System.IO.File.WriteAllText(filepath, "assembly1\r\nassembly2\r\nassembly3\r\n--newinstance\r\n--noactivate"); |
||||||
|
|
||||||
|
var cmdLineArgs = new CommandLineArguments(new string[] { $"@{filepath}" }); |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
System.IO.File.Delete(filepath); |
||||||
|
} |
||||||
|
catch (Exception) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
cmdLineArgs.SingleInstance.Should().BeFalse(); |
||||||
|
cmdLineArgs.NoActivate.Should().BeTrue(); |
||||||
|
cmdLineArgs.AssembliesToLoad.Should().HaveCount(3); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -1,13 +1,13 @@ |
|||||||
{ |
{ |
||||||
"profiles": { |
"profiles": { |
||||||
"ILSpy": { |
"ILSpy": { |
||||||
"commandName": "Executable", |
"commandName": "Executable", |
||||||
"executablePath": ".\\ILSpy.exe", |
"executablePath": "./ilspy.exe", |
||||||
"commandLineArgs": "/separate" |
"commandLineArgs": "--newinstance" |
||||||
}, |
}, |
||||||
"ILSpy single-instance": { |
"ILSpy single-instance": { |
||||||
"commandName": "Executable", |
"commandName": "Executable", |
||||||
"executablePath": ".\\ILSpy.exe" |
"executablePath": "./ilspy.exe" |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
@ -1,54 +1,27 @@ |
|||||||
ILSpy Command Line Arguments |
ILSpy Command Line Arguments |
||||||
|
|
||||||
Command line arguments can be either options or file names. |
Usage: <Assemblies> [options] |
||||||
If an argument is a file name, the file will be opened as assembly and added to the current assembly list. |
@ResponseFile.rsp |
||||||
|
|
||||||
Available options: |
Arguments: |
||||||
/singleInstance If ILSpy is already running, activates the existing instance |
Assemblies Assemblies to load |
||||||
and passes command line arguments to that instance. |
|
||||||
This is the default value if /list is not used. |
|
||||||
|
|
||||||
/separate Start up a separate ILSpy instance even if it is already running. |
|
||||||
|
|
||||||
/noActivate Do not activate the existing ILSpy instance. This option has no effect |
|
||||||
if a new ILSpy instance is being started. |
|
||||||
|
|
||||||
/list:listname Specifies the name of the assembly list that is loaded initially. |
|
||||||
When this option is not specified, ILSpy loads the previously opened list. |
|
||||||
Specify "/list" (without value) to open the default list. |
|
||||||
|
|
||||||
When this option is used, ILSpy will activate an existing instance |
|
||||||
only if it uses the same list as specified. |
|
||||||
|
|
||||||
[Note: Assembly Lists are not yet implemented] |
|
||||||
|
|
||||||
/clearList Clears the assembly list before loading the specified assemblies. |
|
||||||
[Note: Assembly Lists are not yet implemented] |
|
||||||
|
|
||||||
/navigateTo:tag Navigates to the member specified by the given ID string. |
|
||||||
The member is searched for only in the assemblies specified on the command line. |
|
||||||
Example: 'ILSpy ILSpy.exe /navigateTo:T:ICSharpCode.ILSpy.CommandLineArguments' |
|
||||||
|
|
||||||
The syntax of ID strings is described in appendix A of the C# language specification. |
|
||||||
|
|
||||||
/language:name Selects the specified language. |
|
||||||
Example: 'ILSpy /language:C#' or 'ILSpy /language:IL' |
|
||||||
|
|
||||||
WM_COPYDATA (SendMessage API): |
Options: |
||||||
ILSpy can be controlled by other programs that send a WM_COPYDATA message to its main window. |
--newinstance Start a new instance of ILSpy even if the user configuration is set to single-instance |
||||||
The message data must be an Unicode (UTF-16) string starting with "ILSpy:\r\n". |
-n|--navigateto <TYPENAME> Navigates to the member specified by the given ID string. |
||||||
All lines except the first ("ILSpy:") in that string are handled as command-line arguments. |
The member is searched for only in the assemblies specified on the command line. |
||||||
There must be exactly one argument per line. |
Example: 'ILSpy ILSpy.exe --navigateTo:T:ICSharpCode.ILSpy.CommandLineArguments' |
||||||
|
-s|--search <SEARCHTERM> Search for t:TypeName, m:Member or c:Constant; use exact match (=term), |
||||||
That is, by sending this message: |
'should not contain' (-term) or 'must contain' (+term); use |
||||||
ILSpy: |
/reg(ular)?Ex(pressions)?/ or both - t:/Type(Name)?/... |
||||||
C:\Assembly.dll |
-l|--language <LANGUAGEIDENTIFIER> Selects the specified language. |
||||||
/navigateTo:T:Type |
Example: 'ILSpy --language:C#' or 'ILSpy --language:IL' |
||||||
The target ILSpy instance will open C:\Assembly.dll and navigate to the specified type. |
-c|--config <CONFIGFILENAME> Provide a specific configuration file. |
||||||
|
Example: 'ILSpy --config:myconfig.xml' |
||||||
ILSpy will return TRUE (1) if it handles the message, and FALSE (0) otherwise. |
--noactivate Do not activate the existing ILSpy instance. |
||||||
The /separate option will be ignored; WM_COPYDATA will never start up a new instance. |
This option has no effect if a new ILSpy instance is being started. |
||||||
The /noActivate option has no effect, sending WM_COPYDATA will never activate the window. |
|
||||||
Instead, the calling process should use SetForegroundWindow(). |
Note on @ResponseFile.rsp: |
||||||
If you use /list with WM_COPYDATA, you need to specify /singleInstance as well, otherwise |
|
||||||
ILSpy will not handle the message if it has opened a different assembly list. |
* The response file should contain the arguments, one argument per line (not space-separated!). |
||||||
|
* Use it when the list of assemblies is too long to fit on the command line. |
||||||
@ -0,0 +1,13 @@ |
|||||||
|
# For local development of the VSIX package - build and publish (VS2022 also needs arm64) |
||||||
|
|
||||||
|
$output_x64 = "./ILSpy/bin/Debug/net8.0-windows/win-x64/publish/fwdependent" |
||||||
|
|
||||||
|
dotnet publish ./ILSpy/ILSpy.csproj -c Debug --no-restore --no-self-contained -r win-x64 -o $output_x64 |
||||||
|
dotnet publish ./ILSpy.ReadyToRun/ILSpy.ReadyToRun.csproj -c Debug --no-restore --no-self-contained -r win-x64 -o $output_x64 |
||||||
|
dotnet publish ./ILSpy.BamlDecompiler/ILSpy.BamlDecompiler.csproj -c Debug --no-restore --no-self-contained -r win-x64 -o $output_x64 |
||||||
|
|
||||||
|
$output_arm64 = "./ILSpy/bin/Debug/net8.0-windows/win-arm64/publish/fwdependent" |
||||||
|
|
||||||
|
dotnet publish ./ILSpy/ILSpy.csproj -c Debug --no-restore --no-self-contained -r win-arm64 -o $output_arm64 |
||||||
|
dotnet publish ./ILSpy.ReadyToRun/ILSpy.ReadyToRun.csproj -c Debug --no-restore --no-self-contained -r win-arm64 -o $output_arm64 |
||||||
|
dotnet publish ./ILSpy.BamlDecompiler/ILSpy.BamlDecompiler.csproj -c Debug --no-restore --no-self-contained -r win-arm64 -o $output_arm64 |
||||||
Loading…
Reference in new issue