Browse Source

change formatting settings to be consistent with the rest of ILSpy

pull/512/head
Siegfried Pammer 11 years ago
parent
commit
4725c17185
  1. 8
      .editorconfig
  2. 9
      ILSpy.AddIn/ILSpyAddInPackage.cs
  3. 37
      ILSpy.AddIn/Utils.cs

8
.editorconfig

@ -5,11 +5,6 @@ root = true
indent_style = tab indent_style = tab
indent_size = 4 indent_size = 4
# The indentation (and source formatting!) of the addin sources are different than the rest of the solution.
[ILSpy.AddIn/*]
indent_style = space
indent_size = 4
[*.il] [*.il]
indent_style = space indent_style = space
indent_size = 2 indent_size = 2
@ -23,3 +18,6 @@ indent_size = 2
[*.vsixmanifest] [*.vsixmanifest]
indent_style = space indent_style = space
indent_size = 2 indent_size = 2
[*.vsct]
indent_style = space
indent_size = 2

9
ILSpy.AddIn/ILSpyAddInPackage.cs

@ -64,8 +64,7 @@ namespace ICSharpCode.ILSpy.AddIn
// Add our command handlers for menu (commands must exist in the .vsct file) // Add our command handlers for menu (commands must exist in the .vsct file)
OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (null != mcs) if (null != mcs) {
{
// Create the command for the menu item. // Create the command for the menu item.
CommandID menuCommandID = new CommandID(GuidList.guidILSpyAddInCmdSet, (int)PkgCmdIDList.cmdidOpenInILSpy); CommandID menuCommandID = new CommandID(GuidList.guidILSpyAddInCmdSet, (int)PkgCmdIDList.cmdidOpenInILSpy);
MenuCommand menuItem = new MenuCommand(OpenInILSpyCallback, menuCommandID); MenuCommand menuItem = new MenuCommand(OpenInILSpyCallback, menuCommandID);
@ -89,8 +88,7 @@ namespace ICSharpCode.ILSpy.AddIn
var explorer = ((EnvDTE80.DTE2)GetGlobalService(typeof(EnvDTE.DTE))).ToolWindows.SolutionExplorer; var explorer = ((EnvDTE80.DTE2)GetGlobalService(typeof(EnvDTE.DTE))).ToolWindows.SolutionExplorer;
var items = explorer.SelectedItems as EnvDTE.UIHierarchyItem[]; var items = explorer.SelectedItems as EnvDTE.UIHierarchyItem[];
foreach (var item in items) foreach (var item in items) {
{
dynamic obj = item.Object; dynamic obj = item.Object;
OpenAssemblyInILSpy(obj.Path); OpenAssemblyInILSpy(obj.Path);
} }
@ -110,8 +108,7 @@ namespace ICSharpCode.ILSpy.AddIn
private void OpenAssemblyInILSpy(string assemblyFileName) private void OpenAssemblyInILSpy(string assemblyFileName)
{ {
if (!File.Exists(assemblyFileName)) if (!File.Exists(assemblyFileName)) {
{
ShowMessage("Could not find assembly '{0}', please ensure the project and all references were built correctly!", assemblyFileName); ShowMessage("Could not find assembly '{0}', please ensure the project and all references were built correctly!", assemblyFileName);
return; return;
} }

37
ILSpy.AddIn/Utils.cs

@ -36,17 +36,13 @@ namespace ICSharpCode.ILSpy.AddIn
char** arr = CommandLineToArgvW(commandLine, out numberOfArgs); char** arr = CommandLineToArgvW(commandLine, out numberOfArgs);
if (arr == null) if (arr == null)
throw new Win32Exception(); throw new Win32Exception();
try try {
{
string[] result = new string[numberOfArgs]; string[] result = new string[numberOfArgs];
for (int i = 0; i < numberOfArgs; i++) for (int i = 0; i < numberOfArgs; i++) {
{
result[i] = new string(arr[i]); result[i] = new string(arr[i]);
} }
return result; return result;
} } finally {
finally
{
// Free memory obtained by CommandLineToArgW. // Free memory obtained by CommandLineToArgW.
LocalFree(new IntPtr(arr)); LocalFree(new IntPtr(arr));
} }
@ -68,8 +64,7 @@ namespace ICSharpCode.ILSpy.AddIn
if (arguments == null) if (arguments == null)
return null; return null;
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
for (int i = 0; i < arguments.Length; i++) for (int i = 0; i < arguments.Length; i++) {
{
if (i > 0) if (i > 0)
b.Append(' '); b.Append(' ');
AppendArgument(b, arguments[i]); AppendArgument(b, arguments[i]);
@ -79,33 +74,23 @@ namespace ICSharpCode.ILSpy.AddIn
static void AppendArgument(StringBuilder b, string arg) static void AppendArgument(StringBuilder b, string arg)
{ {
if (arg.Length > 0 && arg.IndexOfAny(charsNeedingQuoting) < 0) if (arg.Length > 0 && arg.IndexOfAny(charsNeedingQuoting) < 0) {
{
b.Append(arg); b.Append(arg);
} } else {
else
{
b.Append('"'); b.Append('"');
for (int j = 0; ; j++) for (int j = 0; ; j++) {
{
int backslashCount = 0; int backslashCount = 0;
while (j < arg.Length && arg[j] == '\\') while (j < arg.Length && arg[j] == '\\') {
{
backslashCount++; backslashCount++;
j++; j++;
} }
if (j == arg.Length) if (j == arg.Length) {
{
b.Append('\\', backslashCount * 2); b.Append('\\', backslashCount * 2);
break; break;
} } else if (arg[j] == '"') {
else if (arg[j] == '"')
{
b.Append('\\', backslashCount * 2 + 1); b.Append('\\', backslashCount * 2 + 1);
b.Append('"'); b.Append('"');
} } else {
else
{
b.Append('\\', backslashCount); b.Append('\\', backslashCount);
b.Append(arg[j]); b.Append(arg[j]);
} }

Loading…
Cancel
Save