Skip to content

Commit c8c2ea3

Browse files
authored
Merge branch 'next' into CSharp7
2 parents 7c4e017 + 02982ea commit c8c2ea3

27 files changed

+754
-260
lines changed

CONTRIBUTING.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Contributing to Rubberduck
2+
3+
Thank you very much for taking the time to contribute!
4+
5+
The following is a set of guidelines and links to helpful resources to get you started.
6+
7+
## Code of Conduct
8+
9+
Rubberduck as of now has no formalized Code of Conduct.
10+
Yet the following guidelines apply in no particular order:
11+
12+
- Apply common sense?!
13+
- Show and deserve respect
14+
- Be nice
15+
- We don't bite :)
16+
- Assume people's best intentions unless proven otherwise
17+
18+
## How can I contribute?
19+
20+
### Bug Reports
21+
22+
The development team is always happy to hear about bugs. Reported bugs and other issues are opportunities to make Rubberduck even better.
23+
24+
Before you report your bug, please check the [GitHub Issues](https://github.com/rubberduck-vba/Rubberduck/issues).
25+
The team spends quite some time to label the issues nicely so that you can find already known problems.
26+
27+
To enable the fastest response possible, please include the following information in your Bug report wherever applicable:
28+
29+
- The Version of Rubberduck you are running.
30+
- Steps to reproduce the issue (Code?).
31+
- A **full and complete** logfile, preferrably at TRACE-level
32+
- Screenshots?
33+
- ...
34+
35+
When posting a CLR/JIT stack trace, please avoid cluttering the issue with the "loaded assemblies" part; that (very) long list of loaded DLL's isn't relevant.
36+
37+
### Suggesting Enhancements
38+
39+
The team is always happy to hear your ideas. Please do make sure you checked, whether someone else already requested something similar.
40+
The label [enhancement] will be a good guide.
41+
42+
Do note that despite the rather large scope of Rubberduck, some things are just **too large** or **too complex** for Rubberduck to effectively support.
43+
Please don't be discouraged if your idea gets declined, your feedback is very valuable.
44+
45+
As with Bug Reports the more exact you define what's your gripe, the quicker we can get back to you.
46+
47+
### The Wiki
48+
49+
The Rubberduck Wiki is open for editing to everybody that has a Github account.
50+
This is very much intentional.
51+
Everybody is welcome to improve and expand the wiki.
52+
53+
### Coding and Related
54+
55+
So you want to get your hands dirty and fix that obnoxious bug in the last release?
56+
Well **great**, we like seeing new faces in the fray :)
57+
Or you just want to find something that you can contribute to to learn C#? Or ...
58+
Well whatever your motivation is, we recommend taking a look at issues that are labeled [\[up-for-grabs\]](https://github.com/rubberduck-vba/Rubberduck/issues?q=is%3Aissue+is%3Aopen+label%3Aup-for-grabs).
59+
60+
Our Ducky has come quite the long way and is intimidatingly large for a first-time (or even long-time) contributor.
61+
To make it easier to find something you can do, all issues with that label are additionally labelled with a difficulty.
62+
That difficulty level is a best-guess by the dev-team how complex or evil an issue will be.
63+
64+
If you're new to C#, we recommend you start with \[difficulty-01-duckling\]. The next step \[difficulty-02-ducky\] requires some knowledge about C#, but not so much about how Rubberduck works
65+
66+
Then there's \[difficulty-03-duck\] which requires a good handle on C# and at least an idea of how the components of Rubberduck play toghether.
67+
And finally there's \[difficulty-04-quackhead\] for when you really want to bang your head against the wall.
68+
They require both good knowledge of C# and a deep understanding of how Rubberduck works.
69+
70+
In addition to this, a few people have put together some helpful resources about how Rubberduck works internally and help contributors tell left from right in the ~250k Lines of Code.
71+
72+
You can find their work in the [github wiki](https://github.com/rubberduck-vba/Rubberduck/wiki). If something in there doesn't quite seem to match, it's probably because nobody got around to updating it yet. You're very welcome to **improve** the wiki by adding and correcting information. (see right above)
73+
74+
In case this doesn't quite help you or the information you need hasn't been added to the wiki, you can **always** ask questions.
75+
Please do so in the ["War room"](https://chat.stackexchange.com/rooms/14929).
76+
Note that you will need an account on any of the Stack Exchange sites with at least 20 reputation points to ask questions there.
77+
Other than that, you can also open an issue with the label \[support\], but it may take longer to get back to that.
78+
79+
In that room the core team talks about the duck and whatever else comes up.
80+
N.B.: The rules of the Stack Exchange Network apply to everything you say in that room. But basically those are the same rules as those in the [CoC](#Code_of_Conduct).
81+
82+
Whether you create an issue or a pull request, please avoid using `[` square brackets `]` in the title, and try to be as descriptive (but succinct) as possible. Square brackets in titles confuse our chat-bot, and end up rendering in weird broken ways in SE chat. Avoid riddles, bad puns and other would-be funny (or NSFW) titles that don't really describe the issue or PR.
83+
84+
### Translations
85+
86+
Rubberduck is Localized in multiple languages.
87+
All these translations have been provided by volunteers.
88+
We welcome both new translations as well as improvements to current translations very much.
89+
90+
The resource files are RESX/XML files easily editable in any text editor, but comparing resource keys across languages/translations is much easier done with @Vogel612's [Translation Helper](https://github.com/Vogel612/TranslationHelper) tool, which automatically adds missing keys and highlights entries that need a new translation.
91+
92+
If you contribute a translation for a brand new previously unsupported language, keep in touch with the dev team so that new resource keys can be translated when a new release is coming up; abandoned languages/translations will end up getting dropped.
93+
94+
## What comes out of it for me?
95+
96+
Well ... the eternal gratitude of all Rubberduck users for one :wink:
97+
Aside from that, all contributors are explicitly listed by name (or alias) in the "About Rubberduck" window.
98+
In addition to that, there is some [Contributor-only Rubberduck swag](https://gofundme.com/rubberduckvba), that can be sent to you, at the discretion of @retailcoder.. while supplies last.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Branch | Description | Build Status |
2525
* [Attributions](https://github.com/rubberduck-vba/Rubberduck/blob/next/docs/Attributions.md)
2626
* [About](https://github.com/rubberduck-vba/Rubberduck/blob/next/docs/About.md)
2727
* [Getting Started](https://github.com/rubberduck-vba/Rubberduck/blob/next/docs/GettingStarted.md)
28-
* [Contributing](https://github.com/rubberduck-vba/Rubberduck/wiki/Contributing)
28+
* [Contributing](https://github.com/rubberduck-vba/Rubberduck/blob/next/CONTRIBUTING.md)
2929

3030
---
3131

RetailCoder.VBE/Common/Hotkeys/HotkeyInfo.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,35 @@ public struct HotkeyInfo
99
{
1010
private const Keys Modifiers = Keys.Alt | Keys.Control | Keys.Shift;
1111

12-
private readonly IntPtr _hookId;
13-
private readonly Keys _keys;
14-
1512
public HotkeyInfo(IntPtr hookId, Keys keys)
1613
{
17-
_hookId = hookId;
18-
_keys = keys;
14+
HookId = hookId;
15+
Keys = keys;
1916
}
2017

21-
public IntPtr HookId { get { return _hookId; } }
22-
public Keys Keys { get { return _keys; } }
18+
public IntPtr HookId { get; }
19+
public Keys Keys { get; }
2320

2421
public override string ToString()
2522
{
2623
var builder = new StringBuilder();
27-
if (_keys.HasFlag(Keys.Alt))
24+
if (Keys.HasFlag(Keys.Alt))
2825
{
2926
builder.Append(RubberduckUI.GeneralSettings_HotkeyAlt);
3027
builder.Append('+');
3128
}
32-
if (_keys.HasFlag(Keys.Control))
29+
if (Keys.HasFlag(Keys.Control))
3330
{
3431
builder.Append(RubberduckUI.GeneralSettings_HotkeyCtrl);
3532
builder.Append('+');
3633
}
37-
if (_keys.HasFlag(Keys.Shift))
34+
if (Keys.HasFlag(Keys.Shift))
3835
{
3936
builder.Append(RubberduckUI.GeneralSettings_HotkeyShift);
4037
builder.Append('+');
4138
}
4239

43-
builder.Append(HotkeyDisplayConverter.Convert(_keys & ~Modifiers));
40+
builder.Append(HotkeyDisplayConverter.Convert(Keys & ~Modifiers));
4441
return builder.ToString();
4542
}
4643
}

RetailCoder.VBE/Extension.cs

Lines changed: 64 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
using Rubberduck.Settings;
2020
using Rubberduck.SettingsProvider;
2121
using Rubberduck.VBEditor.Events;
22-
using Rubberduck.VBEditor.SafeComWrappers;
2322
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
2423
using Rubberduck.VBEditor.WindowsApi;
2524
using User32 = Rubberduck.Common.WinAPI.User32;
25+
using Windows = Rubberduck.VBEditor.SafeComWrappers.VBA.Windows;
2626

2727
namespace Rubberduck
2828
{
@@ -204,56 +204,83 @@ private void InitializeAddIn()
204204

205205
private void Startup()
206206
{
207-
var currentDomain = AppDomain.CurrentDomain;
208-
currentDomain.AssemblyResolve += LoadFromSameFolder;
207+
try
208+
{
209+
var currentDomain = AppDomain.CurrentDomain;
210+
currentDomain.UnhandledException += HandlAppDomainException;
211+
currentDomain.AssemblyResolve += LoadFromSameFolder;
212+
213+
_kernel = new StandardKernel(new NinjectSettings {LoadExtensions = true}, new FuncModule(), new DynamicProxyModule());
214+
_kernel.Load(new RubberduckModule(_ide, _addin));
209215

210-
_kernel = new StandardKernel(new NinjectSettings {LoadExtensions = true}, new FuncModule(), new DynamicProxyModule());
211-
_kernel.Load(new RubberduckModule(_ide, _addin));
216+
_app = _kernel.Get<App>();
217+
_app.Startup();
212218

213-
_app = _kernel.Get<App>();
214-
_app.Startup();
219+
_isInitialized = true;
220+
221+
}
222+
catch (Exception e)
223+
{
224+
_logger.Log(LogLevel.Fatal, e, "Startup sequence threw an unexpected exception.");
225+
//throw; // <<~ uncomment to crash the process
226+
}
227+
}
215228

216-
_isInitialized = true;
229+
private void HandlAppDomainException(object sender, UnhandledExceptionEventArgs e)
230+
{
231+
_logger.Log(LogLevel.Fatal, e);
217232
}
218233

219234
private void ShutdownAddIn()
220235
{
221-
Debug.WriteLine("Extension unhooking VBENativeServices events.");
222-
VBENativeServices.UnhookEvents();
223-
224236
var currentDomain = AppDomain.CurrentDomain;
225-
currentDomain.AssemblyResolve -= LoadFromSameFolder;
226-
Debug.WriteLine("Extension broadcasting shutdown.");
227-
User32.EnumChildWindows(_ide.MainWindow.Handle(), EnumCallback, new IntPtr(0));
228-
229-
Debug.WriteLine("Extension calling ReleaseDockableHosts.");
230-
VBEditor.SafeComWrappers.VBA.Windows.ReleaseDockableHosts();
231-
232-
if (_app != null)
233-
{
234-
Debug.WriteLine("Extension calling App.Shutdown.");
235-
_app.Shutdown();
236-
_app = null;
237-
}
238-
239-
if (_kernel != null)
237+
try
240238
{
241-
Debug.WriteLine("Extension calling Kernel.Dispose.");
242-
_kernel.Dispose();
243-
_kernel = null;
244-
}
245-
246-
Debug.WriteLine("Extension: Initiating garbage collection.");
239+
_logger.Log(LogLevel.Info, "Rubberduck is shutting down.");
240+
_logger.Log(LogLevel.Trace, "Unhooking VBENativeServices events...");
241+
VBENativeServices.UnhookEvents();
247242

248-
GC.Collect();
243+
_logger.Log(LogLevel.Trace, "Broadcasting shutdown...");
244+
User32.EnumChildWindows(_ide.MainWindow.Handle(), EnumCallback, new IntPtr(0));
249245

250-
Debug.WriteLine("Extension: Initiated garbage collection.");
246+
_logger.Log(LogLevel.Trace, "Releasing dockable hosts...");
247+
Windows.ReleaseDockableHosts();
251248

252-
GC.WaitForPendingFinalizers();
249+
if (_app != null)
250+
{
251+
_logger.Log(LogLevel.Trace, "Initiating App.Shutdown...");
252+
_app.Shutdown();
253+
_app = null;
254+
}
253255

254-
Debug.WriteLine("Extension: Finalizers have run.");
256+
if (_kernel != null)
257+
{
258+
_logger.Log(LogLevel.Trace, "Disposing IoC container...");
259+
_kernel.Dispose();
260+
_kernel = null;
261+
}
255262

256-
_isInitialized = false;
263+
_isInitialized = false;
264+
_logger.Log(LogLevel.Info, "No exceptions were thrown.");
265+
}
266+
catch (Exception e)
267+
{
268+
_logger.Error(e);
269+
_logger.Log(LogLevel.Warn, "Exception is swallowed.");
270+
//throw; // <<~ uncomment to crash the process
271+
}
272+
finally
273+
{
274+
_logger.Log(LogLevel.Trace, "Unregistering AppDomain handlers....");
275+
currentDomain.AssemblyResolve -= LoadFromSameFolder;
276+
currentDomain.UnhandledException -= HandlAppDomainException;
277+
_logger.Log(LogLevel.Trace, "Done. Initiating garbage collection...");
278+
GC.Collect();
279+
_logger.Log(LogLevel.Trace, "Done. Waiting for pending finalizers...");
280+
GC.WaitForPendingFinalizers();
281+
_logger.Log(LogLevel.Trace, "Done. Shutdown completed. Quack!");
282+
_isInitialized = false;
283+
}
257284
}
258285

259286
private static int EnumCallback(IntPtr hwnd, IntPtr lparam)

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerItemViewModel.cs

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,20 @@ public class CompareByType : Comparer<CodeExplorerItemViewModel>
3131
{
3232
private static readonly Dictionary<DeclarationType, int> SortOrder = new Dictionary<DeclarationType, int>
3333
{
34+
// Some DeclarationTypes we want to treat the same, like Subs and Functions.
35+
// Give them the same number.
3436
{DeclarationType.LibraryFunction, 0},
35-
{DeclarationType.LibraryProcedure, 1},
36-
{DeclarationType.UserDefinedType, 2},
37-
{DeclarationType.Enumeration, 3},
38-
{DeclarationType.Event, 4},
39-
{DeclarationType.Constant, 5},
40-
{DeclarationType.Variable, 6},
41-
{DeclarationType.PropertyGet, 7},
42-
{DeclarationType.PropertyLet, 8},
43-
{DeclarationType.PropertySet, 9},
44-
{DeclarationType.Function, 10},
45-
{DeclarationType.Procedure, 11}
37+
{DeclarationType.LibraryProcedure, 0},
38+
{DeclarationType.UserDefinedType, 1},
39+
{DeclarationType.Enumeration, 2},
40+
{DeclarationType.Event, 3},
41+
{DeclarationType.Constant, 4},
42+
{DeclarationType.Variable, 5},
43+
{DeclarationType.PropertyGet, 6},
44+
{DeclarationType.PropertyLet, 7},
45+
{DeclarationType.PropertySet, 8},
46+
{DeclarationType.Function, 9},
47+
{DeclarationType.Procedure, 9}
4648
};
4749

4850
public override int Compare(CodeExplorerItemViewModel x, CodeExplorerItemViewModel y)
@@ -69,17 +71,21 @@ public override int Compare(CodeExplorerItemViewModel x, CodeExplorerItemViewMod
6971
if (SortOrder.TryGetValue(xNode.Declaration.DeclarationType, out xValue) &&
7072
SortOrder.TryGetValue(yNode.Declaration.DeclarationType, out yValue))
7173
{
72-
return xValue < yValue ? -1 : 1;
74+
if (xValue != yValue)
75+
{ return xValue < yValue ? -1 : 1; }
7376
}
74-
75-
return xNode.Declaration.DeclarationType < yNode.Declaration.DeclarationType ? -1 : 1;
7677
}
7778

78-
if (xNode.Declaration.Accessibility != yNode.Declaration.Accessibility)
79+
// The Tree shows Public and Private Subs/Functions with a seperate icon.
80+
// But Public and Implicit Subs/Functions appear the same, so treat Implicts like Publics.
81+
var xNodeAcc = xNode.Declaration.Accessibility == Accessibility.Implicit ? Accessibility.Public : xNode.Declaration.Accessibility;
82+
var yNodeAcc = yNode.Declaration.Accessibility == Accessibility.Implicit ? Accessibility.Public : yNode.Declaration.Accessibility;
83+
84+
if (xNodeAcc != yNodeAcc)
7985
{
80-
return xNode.Declaration.Accessibility < yNode.Declaration.Accessibility ? -1 : 1;
86+
return xNodeAcc < yNodeAcc ? -1 : 1;
8187
}
82-
88+
8389
if (x.ExpandedIcon != y.ExpandedIcon)
8490
{
8591
// ReSharper disable PossibleInvalidOperationException - this will have a component
@@ -121,12 +127,12 @@ public override int Compare(CodeExplorerItemViewModel x, CodeExplorerItemViewMod
121127
return x.QualifiedSelection.HasValue ? -1 : 1;
122128
}
123129

124-
if (x.QualifiedSelection.Value.Selection == y.QualifiedSelection.Value.Selection)
130+
if (x.QualifiedSelection.Value.Selection.StartLine == y.QualifiedSelection.Value.Selection.StartLine)
125131
{
126132
return 0;
127133
}
128134

129-
return x.QualifiedSelection.Value.Selection < y.QualifiedSelection.Value.Selection ? -1 : 1;
135+
return x.QualifiedSelection.Value.Selection.StartLine < y.QualifiedSelection.Value.Selection.StartLine ? -1 : 1;
130136
}
131137
}
132138

0 commit comments

Comments
 (0)