Skip to content

Commit

Permalink
feat: source.dot.net support
Browse files Browse the repository at this point in the history
  • Loading branch information
vchirikov committed Mar 6, 2020
1 parent 74d9636 commit 5a4c159
Show file tree
Hide file tree
Showing 12 changed files with 827 additions and 198 deletions.
180 changes: 95 additions & 85 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ trim_trailing_whitespace = true
# Visual Studio Solution Files
[*.sln]
indent_style = tab
charset = utf-8

# Visual Studio XML Project Files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2
charset = utf-8

# XML Configuration Files
[*.{xml,config,props,targets,nuspec,resx,ruleset,vsixmanifest,vsct}]
Expand Down Expand Up @@ -112,8 +114,8 @@ csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = false:silent
# Expression-bodied members
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#expression_bodied_members
csharp_style_expression_bodied_methods = true:warning
csharp_style_expression_bodied_constructors = true:warning
csharp_style_expression_bodied_methods = true:none
csharp_style_expression_bodied_constructors = true:none
csharp_style_expression_bodied_operators = true:warning
csharp_style_expression_bodied_properties = true:warning
csharp_style_expression_bodied_indexers = true:warning
Expand Down Expand Up @@ -199,86 +201,94 @@ csharp_space_between_square_brackets = false
#########################

[*.{cs,csx,cake,vb}]
# Naming Symbols
# constant_fields - Define constant fields
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.required_modifiers = const
# non_private_readonly_fields - Define public, internal and protected readonly fields
dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, internal, protected
dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field
dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly
# static_readonly_fields - Define static and readonly fields
dotnet_naming_symbols.static_readonly_fields.applicable_kinds = field
dotnet_naming_symbols.static_readonly_fields.required_modifiers = static, readonly
# private_readonly_fields - Define private readonly fields
dotnet_naming_symbols.private_readonly_fields.applicable_accessibilities = private
dotnet_naming_symbols.private_readonly_fields.applicable_kinds = field
dotnet_naming_symbols.private_readonly_fields.required_modifiers = readonly
# public_internal_fields - Define public and internal fields
dotnet_naming_symbols.public_internal_fields.applicable_accessibilities = public, internal
dotnet_naming_symbols.public_internal_fields.applicable_kinds = field
# private_protected_fields - Define private and protected fields
dotnet_naming_symbols.private_protected_fields.applicable_accessibilities = private, protected
dotnet_naming_symbols.private_protected_fields.applicable_kinds = field
# public_symbols - Define any public symbol
dotnet_naming_symbols.public_symbols.applicable_accessibilities = public, internal, protected, protected_internal
dotnet_naming_symbols.public_symbols.applicable_kinds = method, property, event, delegate
# parameters - Defines any parameter
dotnet_naming_symbols.parameters.applicable_kinds = parameter
# non_interface_types - Defines class, struct, enum and delegate types
dotnet_naming_symbols.non_interface_types.applicable_kinds = class, struct, enum, delegate
# interface_types - Defines interfaces
dotnet_naming_symbols.interface_types.applicable_kinds = interface

# Naming Styles
# camel_case - Define the camelCase style
dotnet_naming_style.camel_case.capitalization = camel_case
# pascal_case - Define the Pascal_case style
dotnet_naming_style.pascal_case.capitalization = pascal_case
# first_upper - The first character must start with an upper-case character
dotnet_naming_style.first_upper.capitalization = first_word_upper
# prefix_interface_interface_with_i - Interfaces must be PascalCase and the first character of an interface must be an 'I'
dotnet_naming_style.prefix_interface_interface_with_i.capitalization = pascal_case
dotnet_naming_style.prefix_interface_interface_with_i.required_prefix = I

# Naming Rules
# Constant fields must be PascalCase
dotnet_naming_rule.constant_fields_must_be_pascal_case.severity = warning
dotnet_naming_rule.constant_fields_must_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_must_be_pascal_case.style = pascal_case
# Public, internal and protected readonly fields must be PascalCase
dotnet_naming_rule.non_private_readonly_fields_must_be_pascal_case.severity = warning
dotnet_naming_rule.non_private_readonly_fields_must_be_pascal_case.symbols = non_private_readonly_fields
dotnet_naming_rule.non_private_readonly_fields_must_be_pascal_case.style = pascal_case
# Static readonly fields must be PascalCase
dotnet_naming_rule.static_readonly_fields_must_be_pascal_case.severity = warning
dotnet_naming_rule.static_readonly_fields_must_be_pascal_case.symbols = static_readonly_fields
dotnet_naming_rule.static_readonly_fields_must_be_pascal_case.style = pascal_case
# Private readonly fields must be camelCase
dotnet_naming_rule.private_readonly_fields_must_be_camel_case.severity = warning
dotnet_naming_rule.private_readonly_fields_must_be_camel_case.symbols = private_readonly_fields
dotnet_naming_rule.private_readonly_fields_must_be_camel_case.style = camel_case
# Public and internal fields must be PascalCase
dotnet_naming_rule.public_internal_fields_must_be_pascal_case.severity = warning
dotnet_naming_rule.public_internal_fields_must_be_pascal_case.symbols = public_internal_fields
dotnet_naming_rule.public_internal_fields_must_be_pascal_case.style = pascal_case
# Private and protected fields must be camelCase
dotnet_naming_rule.private_protected_fields_must_be_camel_case.severity = warning
dotnet_naming_rule.private_protected_fields_must_be_camel_case.symbols = private_protected_fields
dotnet_naming_rule.private_protected_fields_must_be_camel_case.style = camel_case
# Public members must be capitalized
dotnet_naming_rule.public_members_must_be_capitalized.severity = warning
dotnet_naming_rule.public_members_must_be_capitalized.symbols = public_symbols
dotnet_naming_rule.public_members_must_be_capitalized.style = first_upper
# Parameters must be camelCase
dotnet_naming_rule.parameters_must_be_camel_case.severity = warning
dotnet_naming_rule.parameters_must_be_camel_case.symbols = parameters
dotnet_naming_rule.parameters_must_be_camel_case.style = camel_case
# Class, struct, enum and delegates must be PascalCase
dotnet_naming_rule.non_interface_types_must_be_pascal_case.severity = warning
dotnet_naming_rule.non_interface_types_must_be_pascal_case.symbols = non_interface_types
dotnet_naming_rule.non_interface_types_must_be_pascal_case.style = pascal_case
# Interfaces must be PascalCase and start with an 'I'
dotnet_naming_rule.interface_types_must_be_prefixed_with_i.severity = warning
dotnet_naming_rule.interface_types_must_be_prefixed_with_i.symbols = interface_types
dotnet_naming_rule.interface_types_must_be_prefixed_with_i.style = prefix_interface_interface_with_i
charset = utf-8
# Naming Conventions
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions

### Naming Conventions

## Styles

# The basics
dotnet_naming_style.camel_case_style.capitalization = camel_case
dotnet_naming_style.pascal_case_style.capitalization = pascal_case

# Underscore camel style
dotnet_naming_style.camel_case_and_prefix_with_underscore_style.required_prefix = _
dotnet_naming_style.camel_case_and_prefix_with_underscore_style.capitalization = camel_case

# Pascal I prefix
dotnet_naming_style.pascal_case_and_prefix_with_I_style.required_prefix = I
dotnet_naming_style.pascal_case_and_prefix_with_I_style.capitalization = pascal_case

# Pascal T prefix
dotnet_naming_style.pascal_case_and_prefix_with_T_style.required_prefix = T
dotnet_naming_style.pascal_case_and_prefix_with_T_style.capitalization = pascal_case

## Symbols

# Interfaces
dotnet_naming_symbols.interface_symbols.applicable_kinds = interface
dotnet_naming_symbols.interface_symbols.applicable_accessibilities = *

# Type parameters
dotnet_naming_symbols.type_parameter_symbols.applicable_kinds = type_parameter
dotnet_naming_symbols.type_parameter_symbols.applicable_accessibilities = *

# Pascal most of the things
dotnet_naming_symbols.pascal_symbols.applicable_kinds = class, struct, enum, property, method, event, namespace, delegate, local_function
dotnet_naming_symbols.pascal_symbols.applicable_accessibilities = *

# Parameters, locals
dotnet_naming_symbols.locals_and_parameters_symbols.applicable_kinds = parameter, local
dotnet_naming_symbols.locals_and_parameters_symbols.applicable_accessibilities = *

# Constants
dotnet_naming_symbols.constant_symbols.applicable_kinds = field
dotnet_naming_symbols.constant_symbols.required_modifiers = const
dotnet_naming_symbols.constant_symbols.applicable_accessibilities = *

# Public fields
dotnet_naming_symbols.public_field_symbols.applicable_kinds = field
dotnet_naming_symbols.public_field_symbols.applicable_accessibilities = public, friend, protected, protected_friend, private_protected

# Private fields
dotnet_naming_symbols.private_field_symbols.applicable_kinds = field
dotnet_naming_symbols.private_field_symbols.applicable_accessibilities = private, internal, protected_internal

## Naming Rules

# Interfaces
dotnet_naming_rule.interfaces_must_be_pascal_cased_and_prefixed_with_I.symbols = interface_symbols
dotnet_naming_rule.interfaces_must_be_pascal_cased_and_prefixed_with_I.style = pascal_case_and_prefix_with_I_style
dotnet_naming_rule.interfaces_must_be_pascal_cased_and_prefixed_with_I.severity = warning

# Type parameters
dotnet_naming_rule.type_parameters_must_be_pascal_cased_and_prefixed_with_T.symbols = type_parameter_symbols
dotnet_naming_rule.type_parameters_must_be_pascal_cased_and_prefixed_with_T.style = pascal_case_and_prefix_with_T_style
dotnet_naming_rule.type_parameters_must_be_pascal_cased_and_prefixed_with_T.severity = warning

# Pascal most of the things
dotnet_naming_rule.externally_visible_members_must_be_pascal_cased.symbols = pascal_symbols
dotnet_naming_rule.externally_visible_members_must_be_pascal_cased.style = pascal_case_style
dotnet_naming_rule.externally_visible_members_must_be_pascal_cased.severity = warning

# Parameters, locals
dotnet_naming_rule.parameters_must_be_camel_cased.symbols = locals_and_parameters_symbols
dotnet_naming_rule.parameters_must_be_camel_cased.style = camel_case_style
dotnet_naming_rule.parameters_must_be_camel_cased.severity = warning

# Constants
dotnet_naming_rule.constants_must_be_pascal_cased.symbols = constant_symbols
dotnet_naming_rule.constants_must_be_pascal_cased.style = pascal_case_style
dotnet_naming_rule.constants_must_be_pascal_cased.severity = warning

# Public fields
dotnet_naming_rule.public_instance_fields_must_be_camel_cased_and_prefixed_with_underscore.symbols = public_field_symbols
dotnet_naming_rule.public_instance_fields_must_be_camel_cased_and_prefixed_with_underscore.style = pascal_case_style
dotnet_naming_rule.public_instance_fields_must_be_camel_cased_and_prefixed_with_underscore.severity = warning

# Private fields
dotnet_naming_rule.private_instance_fields_must_be_camel_cased_and_prefixed_with_underscore.symbols = private_field_symbols
dotnet_naming_rule.private_instance_fields_must_be_camel_cased_and_prefixed_with_underscore.style = camel_case_and_prefix_with_underscore_style
dotnet_naming_rule.private_instance_fields_must_be_camel_cased_and_prefixed_with_underscore.severity = warning
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
build.ps1
build.sh
# Cake tools
build/tools/
tools/
# Can contain personal info

**/Properties/launchSettings.json
Expand Down Expand Up @@ -247,5 +247,5 @@ _Pvt_Extensions
# FAKE - F# Make
.fake/
/CodeMaid.config
**/node_modules
/desktop.ini
/package-lock.json
8 changes: 5 additions & 3 deletions GoToDnSpy.sln
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26403.7
# Visual Studio Version 16
VisualStudioVersion = 16.0.29827.131
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GoToDnSpy", "src\GoToDnSpy\GoToDnSpy.csproj", "{EBF7F9EF-6EE3-4612-88CB-3EAD17DF0EF0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DFC8C3DA-F2B1-43D2-B6FF-F049FF6E8A9C}"
ProjectSection(SolutionItems) = preProject
package.json = package.json
Readme.md = Readme.md
EndProjectSection
EndProject
Expand All @@ -25,4 +24,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1074D07E-0D1B-4A32-8456-C116EC7D6084}
EndGlobalSection
EndGlobal
17 changes: 9 additions & 8 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

## Introduction

Sometimes I need something like Resharper command "Navigate To Decompiled Sources", but I don't want to buy and install R# only for this command. So I created this plugin for quick access to dnSpy.
BTW, after VS 2017.6 Preview can do it with included ILSpy.

Sometimes I need something like Resharper command "Navigate To Decompiled Sources", but I don't want to buy and use R# only for this command. So I have created this plugin for quick access to dnSpy or corefx sources.

[dnSpy](https://github.com/0xd4d/dnSpy/) is the best tool for .net reseacher.
You can [download latest dnSpy build](https://ci.appveyor.com/project/0xd4d/dnspy/branch/master/artifacts) from CI.
Expand All @@ -13,7 +11,7 @@ You can [download latest dnSpy build](https://ci.appveyor.com/project/0xd4d/dnsp

Plugin can be found in [Visual Studio marketplace](https://marketplace.visualstudio.com/items?itemName=VladimirChirikov.GoToDnSpy).

**Please send positive feedback if you liked the extension :)**
**Please send positive feedback if you like the extension :)**

## Preview

Expand All @@ -22,20 +20,23 @@ Plugin can be found in [Visual Studio marketplace](https://marketplace.visualstu

## Options

For work plugin need put path to installed dnSpy in options page.
The plugin needs the path to installed dnSpy on options page.
You can [download latest dnSpy build](https://ci.appveyor.com/project/0xd4d/dnspy/branch/master/artifacts) from CI.

![Options GoToDnSpy](docs/img/options.png)

## Using

Place cursor at referenced code (method, event, etc) and run "GoTo dnSpy..." command.
Place cursor at the code (method, event, etc) and run "GoTo dnSpy..." command.

GoToDnSpy command can be found in Visual Studio tools menu
GoToDnSpy command can be found in Visual Studio tools and right-click context menu.

![Tools menu with GoTo dnSpy](docs/img/tools_menu.png)

You can add and use a shortcut for fast run command
If this is a runtime libraries code the plugin will run a browser with [source.dot.net](https://source.dot.net).


You can add and use a shortcut to quickly launch the command.

![Shortcut example](docs/img/shortcut.png)

Expand Down
26 changes: 12 additions & 14 deletions src/GoToDnSpy/EnvDteExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EnvDTE;
using Microsoft.VisualStudio.ProjectSystem.Properties;
using Microsoft.VisualStudio.ProjectSystem.VS;
using Microsoft.VisualStudio.Shell;
using VSLangProj80;

namespace GoToDnSpy
{

internal static class EnvDteExtensions
{
public static T FindByNameOrDefault<T>(this Properties properties, string name)
Expand All @@ -29,7 +25,6 @@ public static T FindByNameOrDefault<T>(this Properties properties, string name)
return default;
}


public static ProjectItem FindByNameOrDefault(this ProjectItems collection, string name, bool recursive = false)
{
if (collection == null)
Expand All @@ -39,7 +34,7 @@ public static ProjectItem FindByNameOrDefault(this ProjectItems collection, stri

foreach (ProjectItem item in collection)
{
if (string.Compare(item.Name, name, StringComparison.Ordinal) == 0)
if (string.Equals(item.Name, name, StringComparison.Ordinal))
return item;

if (recursive)
Expand All @@ -54,14 +49,13 @@ public static ProjectItem FindByNameOrDefault(this ProjectItems collection, stri
return null;
}


public static EnvDTE.ProjectItem FindProjectItemByNameOrDefault(this Project project, string name, bool recursive) // directory tree recursive find of files
{
ThreadHelper.ThrowIfNotOnUIThread();
// if it's real project we can use find
if (project.Kind != EnvDTE.Constants.vsProjectKindSolutionItems)
{
if (project.ProjectItems != null && project.ProjectItems.Count > 0)
if (project.ProjectItems?.Count > 0)
return project.ProjectItems.FindByNameOrDefault(name, recursive);
else
return null;
Expand All @@ -84,11 +78,10 @@ public static EnvDTE.ProjectItem FindProjectItemByNameOrDefault(this Project pro
/// </summary>
private static string GetProjectPropertyNetCoreWorkaround(this Project project, string name)
{
var context = (IVsBrowseObjectContext) project;
var unconfiguredProject = context.UnconfiguredProject;
var unconfiguredProject = project.AsUnconfiguredProject();
var configuredProject = unconfiguredProject.GetSuggestedConfiguredProjectAsync().ConfigureAwait(false).GetAwaiter().GetResult();
var properties = configuredProject.Services.ProjectPropertiesProvider.GetCommonProperties();
return properties.GetEvaluatedPropertyValueAsync(name).ConfigureAwait(false).GetAwaiter().GetResult(); ;
return properties.GetEvaluatedPropertyValueAsync(name).ConfigureAwait(false).GetAwaiter().GetResult();
}

/// <summary>
Expand All @@ -100,7 +93,12 @@ private static string GetProjectPropertyNetCoreWorkaround(this Project project,
public static string GetPropertyOrDefault(this Project project, string name)
{
ThreadHelper.ThrowIfNotOnUIThread();
return (project.Properties.FindByNameOrDefault<string>(name) ?? project.GetProjectPropertyNetCoreWorkaround(name))?.Trim();
return (project.Properties.FindByNameOrDefault<string>(name)
?? project.ConfigurationManager?.ActiveConfiguration?.Properties.FindByNameOrDefault<string>(name)
?? (project.Properties as ProjectConfigurationProperties3)?.OutputPath
?? (project.Properties.Item(name).Value?.ToString())
?? project.GetProjectPropertyNetCoreWorkaround(name)
)?.Trim();
}

/// <summary>
Expand Down
Loading

0 comments on commit 5a4c159

Please sign in to comment.