diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ce308d0dfa..86dc22dfd3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -61,15 +61,15 @@ Our Ducky has come quite the long way and is intimidatingly large for a first-ti To make it easier to find something you can do, all issues with that label are additionally labelled with a difficulty. That difficulty level is a best-guess by the dev-team how complex or evil an issue will be. -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 +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 - 02/ducky issues usually make a good introduction to using Rubberduck's internal API. -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. +Then there's \[difficulty-03-duck\] which requires a good handle on C# and how the components of Rubberduck play toghether. And finally there's \[difficulty-04-quackhead\] for when you really want to bang your head against the wall. -They require both good knowledge of C# and a deep understanding of how Rubberduck works. +They require both good knowledge of C# and a deep understanding of how not only Rubberduck, but also COM and well, the VBE, works. 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. -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) +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) 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. Please do so in the ["War room"](https://chat.stackexchange.com/rooms/14929). @@ -79,21 +79,21 @@ Other than that, you can also open an issue with the label \[support\], but it m In that room the core team talks about the duck and whatever else comes up. 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). -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. +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*. ### Translations -Rubberduck is Localized in multiple languages. +Rubberduck is localized in multiple languages. All these translations have been provided by volunteers. We welcome both new translations as well as improvements to current translations very much. -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. +The resource files are RESX/XML files easily editable in any text editor, but our recommendation goes to the [ResXManager](https://marketplace.visualstudio.com/items?itemName=TomEnglert.ResXManager) Visual Studio plug-in: -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. +![ResXManager in Visual Studio](https://user-images.githubusercontent.com/5751684/48683625-1a07f000-eb7c-11e8-914a-10ed80e85e29.png) + +If you contribute a translation for a brand new previously unsupported language, please 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. ## What comes out of it for me? -Well ... the eternal gratitude of all Rubberduck users for one :wink: +Well... the eternal gratitude of all Rubberduck users for one :wink: Aside from that, all contributors are explicitly listed by name (or alias) in the "About Rubberduck" window. - -We ran a [fundraiser](https://gofundme.com/rubberduckvba) last summer, and had t-sihrts, mugs, pens, and stickers made - the goods are now unfortunately depleted; we'll probably run another campaign next year! diff --git a/README.md b/README.md index 4be14947cb..51e6a74056 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ - - +Rubberduck Open-Source VBE Add-In - VBA6 | VBA7 x86/x64 | VB6 + - 2.2 + 2.3.0 @@ -65,6 +65,7 @@ 2.7.6684 + 1.8.4 @@ -81,7 +82,20 @@ 2.0.20525 - + + + True + True + Settings.settings + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + @@ -98,38 +112,4 @@ - - - - Designer - MSBuild:Compile - - - Code - %(Filename) - - - - Resources.resx - true - true - - - Resources.Designer.cs - ResXFileCodeGenerator - - - - True - True - Settings.settings - True - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - \ No newline at end of file diff --git a/Rubberduck.Core/Settings/GeneralSettings.cs b/Rubberduck.Core/Settings/GeneralSettings.cs index 8446eed04c..a16d961004 100644 --- a/Rubberduck.Core/Settings/GeneralSettings.cs +++ b/Rubberduck.Core/Settings/GeneralSettings.cs @@ -19,6 +19,9 @@ public interface IGeneralSettings bool UserEditedLogLevel { get; set; } int MinimumLogLevel { get; set; } List EnableExperimentalFeatures { get; set; } + int RecentReferencesTracked { get; set; } + List RecentReferences { get; set; } + List PinnedReferences { get; set; } } [SettingsSerializeAs(SettingsSerializeAs.Xml)] @@ -58,6 +61,10 @@ public int MinimumLogLevel public List EnableExperimentalFeatures { get; set; } = new List(); + public int RecentReferencesTracked { get; set; } + public List RecentReferences { get; set; } + public List PinnedReferences { get; set; } + public GeneralSettings() { //Enforce non-default default value for members @@ -78,8 +85,11 @@ public bool Equals(GeneralSettings other) AutoSavePeriod == other.AutoSavePeriod && UserEditedLogLevel == other.UserEditedLogLevel && MinimumLogLevel == other.MinimumLogLevel && - EnableExperimentalFeatures.All(a => other.EnableExperimentalFeatures.Contains(a)) && - EnableExperimentalFeatures.Count == other.EnableExperimentalFeatures.Count; + RecentReferencesTracked == other.RecentReferencesTracked && + EnableExperimentalFeatures.Count == other.EnableExperimentalFeatures.Count && + EnableExperimentalFeatures.All(other.EnableExperimentalFeatures.Contains) && + RecentReferences.SequenceEqual(other.RecentReferences, StringComparer.OrdinalIgnoreCase) && + PinnedReferences.OrderBy(x => x).SequenceEqual(other.PinnedReferences.OrderBy(x => x), StringComparer.OrdinalIgnoreCase); } } } \ No newline at end of file diff --git a/Rubberduck.Core/Templates/ITemplate.cs b/Rubberduck.Core/Templates/ITemplate.cs new file mode 100644 index 0000000000..370930f80c --- /dev/null +++ b/Rubberduck.Core/Templates/ITemplate.cs @@ -0,0 +1,12 @@ +namespace Rubberduck.Templates +{ + public interface ITemplate + { + string Name { get; } + bool IsUserDefined { get; } + string Caption { get; } + string Description { get; } + string Read(); + void Write(string content); + } +} \ No newline at end of file diff --git a/Rubberduck.Core/Templates/Template.cs b/Rubberduck.Core/Templates/Template.cs new file mode 100644 index 0000000000..5059c35d8a --- /dev/null +++ b/Rubberduck.Core/Templates/Template.cs @@ -0,0 +1,69 @@ +namespace Rubberduck.Templates +{ + /// + /// Template can be either built-in or user-defined. For a built-in template, the + /// metadata should be stored in the + /// resource, with specific entries, currently Name, Caption, Description and Code. + /// Due to the fact that we cannot strong-type the reference to the resource entries + /// the class has unit tests to validate that the crucial elements are present in the + /// resource to guard against runtime errors/unexpected behavior due to missing/malformed + /// entries in the resources. + /// + public class Template : ITemplate + { + private readonly ITemplateFileHandler _handler; + public Template(string name, ITemplateFileHandler handler) + { + _handler = handler; + + Name = name; + IsUserDefined = VerifyIfUserDefined(name); + + if (IsUserDefined) + { + //TODO: Devise a way for users to define their captions/descriptions simply + Caption = Name; + Description = Name; + } + else + { + VerifyFile(name, handler); + (Caption, Description) = GetBuiltInMetaData(name); + } + } + + public string Name { get; } + public bool IsUserDefined { get; } + public string Caption { get; } + public string Description { get; } + + public string Read() => _handler.Read(); + + public void Write(string content) => _handler.Write(content); + + private static bool VerifyIfUserDefined(string name) + { + var builtInName = Resources.Templates.ResourceManager.GetString(name + "_Name"); + return builtInName == null || builtInName != name; + } + + private static void VerifyFile(string name, ITemplateFileHandler handler) + { + if (handler.Exists) + { + return; + } + + var content = Resources.Templates.ResourceManager.GetString(name + "_Code"); + handler.Write(content); + } + + private static (string caption, string description) GetBuiltInMetaData(string name) + { + var caption = Resources.Templates.ResourceManager.GetString(name + "_Caption"); + var description = Resources.Templates.ResourceManager.GetString(name + "_Description"); + + return (caption, description); + } + } +} \ No newline at end of file diff --git a/Rubberduck.Core/Templates/TemplateFileHandler.cs b/Rubberduck.Core/Templates/TemplateFileHandler.cs new file mode 100644 index 0000000000..b093b114d9 --- /dev/null +++ b/Rubberduck.Core/Templates/TemplateFileHandler.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Rubberduck.SettingsProvider; + +namespace Rubberduck.Templates +{ + public interface ITemplateFileHandlerProvider + { + ITemplateFileHandler CreateTemplateFileHandler(string templateName); + IEnumerable GetTemplateNames(); + } + + public class TemplateFileHandlerProvider : ITemplateFileHandlerProvider + { + private readonly string _rootPath; + + public TemplateFileHandlerProvider(IPersistancePathProvider pathProvider) + { + _rootPath = pathProvider.DataFolderPath("Templates"); + } + + public ITemplateFileHandler CreateTemplateFileHandler(string templateName) + { + if (!Directory.Exists(_rootPath)) + { + Directory.CreateDirectory(_rootPath); + } + + var fullPath = Path.Combine(_rootPath, templateName); + if (!Directory.Exists(Path.GetDirectoryName(fullPath))) + { + throw new InvalidOperationException("Cannot provide a path for where the parent directory do not exist"); + } + return new TemplateFileHandler(fullPath); + } + + public IEnumerable GetTemplateNames() + { + var info = new DirectoryInfo(_rootPath); + return info.GetFiles().Select(file => file.Name).ToList(); + } + } + + public interface ITemplateFileHandler + { + bool Exists { get; } + string Read(); + void Write(string content); + } + + public class TemplateFileHandler : ITemplateFileHandler + { + private readonly string _fullPath; + + public TemplateFileHandler(string fullPath) + { + _fullPath = fullPath + (fullPath.EndsWith(".rdt") ? string.Empty : ".rdt"); + } + + public bool Exists => File.Exists(_fullPath); + + public string Read() + { + return Exists ? File.ReadAllText(_fullPath) : null; + } + + public void Write(string content) + { + File.WriteAllText(_fullPath, content); + } + } +} \ No newline at end of file diff --git a/Rubberduck.Core/Templates/TemplateProvider.cs b/Rubberduck.Core/Templates/TemplateProvider.cs new file mode 100644 index 0000000000..a1c931ab9a --- /dev/null +++ b/Rubberduck.Core/Templates/TemplateProvider.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; + +namespace Rubberduck.Templates +{ + public interface ITemplateProvider + { + ITemplate Load(string templateName); + IEnumerable