diff --git a/.editorconfig b/.editorconfig index 01b0d7fe..38ac5702 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,7 +10,10 @@ charset = utf-8 [*.sln] indent_style = tab -[*.{csproj,yml,nuspec},packages.config] +[*.{csproj,yml,nuspec}] +indent_size = 2 + +[packages.config] indent_size = 2 [*.md] diff --git a/.gitignore b/.gitignore index 0fa61b1f..ce32dab0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ *.suo *.user *.sln.docstates +.vs/ # Build results [Dd]ebug/ @@ -150,7 +151,6 @@ AppPackages/ sql/ *.Cache ClientBin/ -[Ss]tyle[Cc]op.* ~$* *~ *.dbmdl diff --git a/.nuget/packages.config b/.nuget/packages.config deleted file mode 100644 index ab908da6..00000000 --- a/.nuget/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 66127a75..27bdf310 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,7 +7,8 @@ In order to make the code neat, readable, and organized properly, there are some Always remember, if you are unsure about something: check the existing source to get an idea of how things should look! If you have more specific questions about the guidelines or other things about the project, feel free to contact anyone -listed under `PRIMARY AUTHORS` in the [AUTHORS file][authors] or [create an issue][] in the [main repo][]. +listed under `PRIMARY AUTHORS` in the [AUTHORS file][authors] or [create an issue][] in the [main repo][]. You can also +[join the Gitter chat][gitter] and ask your questions. ## Cloning the repo @@ -22,21 +23,53 @@ git clone git@github.com:/Colore.git * Design your code to be event-driven when possible, it makes it easier for applications to implement the library. * Follow common C# practices for cleaner looking code (properties instead of `Get` methods, for example). +## Development requirements + +*2015-12-22:* With Colore now being written using C# 6.0 features, you will need to use an edition of +Visual Studio 2015 to develop on Colore. + ## StyleCop -Colore has a config file included for use with [StyleCop][], follow anything StyleCop tells you **if you are using the config file supplied with Colore**. +*Updated 2015-12-22: Colore is now on C# 6.0 which meant a move from the old StyleCop package to the new +StyleCop.Analyzers package which implements StyleCop rules as Roslyn analyzers.* + +Colore references the [StyleCop.Analyzers][stylecopanalyzers] package, +which will analyze the code and point out any errors. + +A global ruleset file `Corale.Colore.ruleset` provided with Colore defines the rules we use for Colore and will be +used by analyzing tools automatically. -If StyleCop and this guide contradict each other, **always** follow what StyleCop tells you (assuming you are using the supplied config). +If there are any conflicts between this guide and what StyleCop tells you, **always follow what StyleCop says**. +This guide may not always be up to date with the latest changes to what rules we are using. If you feel unsure, +feel free to create an issue or contact the primary developers or post a question in the [Gitter][gitter] chat room. ### StyleCop exception cases -During the early development of Colore, StyleCop may not be properly configured with all rules yet. -If you feel unsure about whether a certain StyleCop rule should *really* be followed, feel free to [create an issue][] with your question. + +If you feel unsure about whether a certain StyleCop rule should *really* be followed, +feel free to [create an issue][] with your question. You may also submit a pull request with your changes and we will notify you if something looks wrong. +## ReSharper + +ReSharper is used by the primary developers of Colore and as such, we provide a setting file with Colore that +configures ReSharper with the settings we recommend using (such as naming conventions). If you use ReSharper, +make sure that the *team-shared* settings are being used. + +### StyleCop plugin in ReSharper + +Currently (2015-12-22) there seem to be issues with the StyleCop plugin in ReSharper (regardless of which version +is used) which makes ReSharper perform StyleCop analysis according to the default ruleset even if the +`StyleCop.Analyzers` package is installed. We therefore recommend *disabling the StyleCop plugin in ReSharper* +if it isn't already. + ## Mandatory file header -The following file header **must be present in every code file**, if it is missing your code will not be accepted until the header has been put in place. +The following file header **must be present in every code file**, if it is missing your code will not be accepted until +the header has been put in place. + +Invalid or missing file headers are detected by the StyleCop analyzers and can be remedied by utilizing the provided +quick fix from within the editor. ``` // --------------------------------------------------------------------------------------- @@ -60,11 +93,6 @@ The following file header **must be present in every code file**, if it is missi // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -// Disclaimer: Corale and/or Colore is in no way affiliated with Razer and/or any -// of its employees and/or licensors. Corale, Adam Hellberg, and/or Brandon Scott -// do not take responsibility for any harm caused, direct or indirect, to any -// Razer peripherals via the use of Colore. -// // "Razer" is a trademark of Razer USA Ltd. // // --------------------------------------------------------------------------------------- @@ -72,7 +100,8 @@ The following file header **must be present in every code file**, if it is missi ## Indenting -Use 4 **spaces** for indenting (**not tabs!**). No more, no less. Every decent IDE (and even text editor) lets you change this. +Use 4 **spaces** for indenting (**not tabs!**). No more, no less. +Every decent IDE (and even text editor) lets you change this. Code with incorrect indentation will not be accepted until corrected. @@ -80,7 +109,8 @@ Code with incorrect indentation will not be accepted until corrected. *StyleCop will notify you about incorrect using statements.* -Put using statements as deep as possible (usually it will be just after the namespace declaration) and in alphabetical order. +Put using statements as deep as possible (usually it will be just after the namespace declaration) +and in alphabetical order. `System.*` namespaces are always put at the top in their own alphabetical order. @@ -98,7 +128,9 @@ using SomeAuthor.SomeLib; ## Naming -StyleCop will tell you how to name things most of the time. The only thing worth mentioning is that private fields are named by prefixing them with an underscore. The only exception is for `const` and `static readonly` in which case they are named using PascalCase. +StyleCop will tell you how to name things most of the time. The only thing worth mentioning is that private fields +are named by prefixing them with an underscore. The only exception is for `const` and `static readonly` in which case +they are named using PascalCase. ```c# // Naming example for a private variable @@ -112,15 +144,18 @@ If you are using ReSharper, it will manage this for you, as we are using its def ### Exceptions to naming convention -You should always try to name everything in a C#-idiomatic way, but we may make exceptions for exceptional cases, like when importing native code fragments. +You should always try to name everything in a C#-idiomatic way, but we may make exceptions for exceptional cases, +like when importing native code fragments. ## Exception throwing and handling Try not to catch the base `Exception` class, always catch specific exceptions that you are certain your code can handle. -When throwing exceptions, throw a type that is relevant to the error that occurred, don't throw a base `Exception` if an argument is `null`, throw the `ArgumentNullException`. +When throwing exceptions, throw a type that is relevant to the error that occurred, don't throw a base `Exception` +if an argument is `null`, throw the `ArgumentNullException`. -If creating custom exception types, append `Exception` to the name and inherit from the relevant base exception class, as per usual C# guidelines. Try to keep exception names short but descriptive. +If creating custom exception types, append `Exception` to the name and inherit from the relevant base exception class, +as per usual C# guidelines. Try to keep exception names short but descriptive. ## Usage of the `var` keyword @@ -128,11 +163,13 @@ With fancy IDEs and other tools, the need to explicitly specify the type of a va If you look through the source, you'll find that the `var` keyword is used extensively. -However, whether or not you use the `var` keyword doesn't matter too much. If you find a piece of code more readable with the full type name, then write the full type name. +However, whether or not you use the `var` keyword doesn't matter too much. If you find a piece of code more +readable with the full type name, then write the full type name. Use your own judgement to decide whether using the `var` keyword makes your code more readable. -That said, there are situations where using the `var` keyword is strongly encouraged, when the type name is mentioned in the statement (typically on assignment operations): +That said, there are situations where using the `var` keyword is strongly encouraged, when the type name is mentioned +in the statement (typically on assignment operations): ```c# // Consider this line of code: @@ -143,11 +180,15 @@ var myArray = new SpecialSuperType[10]; ## Calling native Chroma SDK functions -**Never call native SDK functions directly**. If implementing new SDK functions, add a wrapper function for them in [NativeWrapper.cs][nativewrapper] first, then call them using that wrapper. Look at the existing code in the file for an idea of how they are written. The bare requirement for a wrapper function is that it must encapsulate and isolate the API call fully and handle the returned result value, throwing a `NativeCallException` if it failed. +**Never call native SDK functions directly**. If implementing new SDK functions, add a wrapper function for them in +[NativeWrapper.cs][nativewrapper] first, then call them using that wrapper. Look at the existing code in the file for +an idea of how they are written. The bare requirement for a wrapper function is that it must encapsulate and isolate +the API call fully and handle the returned result value, throwing a `NativeCallException` if it failed. ## Documenting your code -Public-facing components of your code **must** have documentation. We will not merge pull requests that are missing documentation on public members. +Public-facing components of your code **must** have documentation. We will not merge pull requests that are missing +documentation on public members. Use standard C# XML documentation comments for documenting your code, like so: @@ -163,29 +204,53 @@ public bool OpenWebpage(string url) } ``` -If you are using Visual Studio, it will automatically insert the proper tags for you when you type three slashes where applicable (`///`). +If you are using Visual Studio, it will automatically insert the proper tags for you when you type three slashes +where applicable (`///`). -Please use proper grammar and punctuation in your documentation comments for the convenience of the reader. We understand that not everyone is a native English speaker or have perfect language skills, and so we are pretty relaxed with the proper-ness of documentation comments. +Please use proper grammar and punctuation in your documentation comments for the convenience of the reader. +We understand that not everyone is a native English speaker or have perfect language skills, and so we are pretty +relaxed with the proper-ness of documentation comments. -Simply: Badly written documentation comments are still better than no documentation comments at all. The important thing is that you can write something understandable. We will tell you in the pull request if there's something you can improve before we merge it. +Simply: Badly written documentation comments are still better than no documentation comments at all. +The important thing is that you can write something understandable. We will tell you in the pull request if there's +something you can improve before we merge it. -If you're referencing/importing/wrapping functions from external sources like the WinAPI or Razer's APIs you can simply copy documentation from the original source (MSDN for example). This usually means you get properly written documentation that is easy (ok, most of the time anyway) to understand. +If you're referencing/importing/wrapping functions from external sources like the WinAPI or Razer's APIs you can simply +copy documentation from the original source (MSDN for example). This usually means you get properly written +documentation that is easy (ok, most of the time anyway) to understand. ## Submitting a pull request -Good, we didn't scare you off with all these requirements, and you are on your way to submitting your first pull request! (Hopefully). +Good, we didn't scare you off with all these requirements, +and you are on your way to submitting your first pull request! (Hopefully). -When making a pull request, if is often convenient to make a branch just for that request (so that you can continue working on your main development branch while your pull request is being reviewed). These branches are typically named `patch-` but can be anything you desire, like a descriptive name for what the PR is about. If you decide to name branches based on the change, make sure you keep them quite short. +When making a pull request, if is often convenient to make a branch just for that request (so that you can continue +working on your main development branch while your pull request is being reviewed). These branches are typically +named `patch-` but can be anything you desire, like a descriptive name for what the PR is about. If you +decide to name branches based on the change, make sure you keep them quite short. -Another very positive thing for both you and us, the maintainers, is to avoid pull requests with a lot of commits that don't share anything in common. Imagine if you submit a pull request that implements a car and a bicycle. We decide that we like your car implementation, but not the bicycle one. But we can't choose, as you put them both in the same pull request! +Another very positive thing for both you and us, the maintainers, is to avoid pull requests with a lot of commits that +don't share anything in common. Imagine if you submit a pull request that implements a car and a bicycle. We decide +that we like your car implementation, but not the bicycle one. But we can't choose, as you put them both in the +same pull request! So always make sure that your pull request is handling **one type of feature or change**. -Other things to keep in mind is to include details about what your feature or change is about in the pull request message. The more information the better! And make sure to give your pull request a relevant name, too. +Other things to keep in mind is to include details about what your feature or change is about in the pull request +message. The more information the better! And make sure to give your pull request a relevant name, too. ### Pull request target branch -When submitting your pull request, make sure you are targeting the [`develop`][develop] branch of the main repo. If you target the wrong branch we will close your pull request. Don't feel bad though, just re-create it with the correct target branch! (We have to close it as GitHub does not support changing the target branch on an existing pull request.) +When submitting your pull request, make sure you are targeting the [`develop`][develop] branch of the main repo. +If you target the wrong branch we will close your pull request. Don't feel bad though, just re-create it with the +correct target branch! (We have to close it as GitHub does not support changing the target +branch on an existing pull request.) + +#### Hotfixes + +Hotfixes are special, and are treated differently than other branches. A hotfix is branched from master and merged +back into master and then to develop. If you ever write a hotfix, keep this in mind. **Hotfixes branch from master, +*not develop*.** [AUTHORS]: AUTHORS [create an issue]: https://github.com/CoraleStudios/Colore/issues/new @@ -193,3 +258,5 @@ When submitting your pull request, make sure you are targeting the [`develop`][d [StyleCop]: http://stylecop.codeplex.com/ [nativewrapper]: Colore/Core/NativeWrapper.cs [develop]: https://github.com/CoraleStudios/Colore/tree/develop +[gitter]: https://gitter.im/CoraleStudios/Colore?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge +[stylecopanalyzers]: https://github.com/DotNetAnalyzers/StyleCopAnalyzers diff --git a/Corale.Colore.Tester/App.xaml b/Corale.Colore.Tester/App.xaml new file mode 100644 index 00000000..3e6a849b --- /dev/null +++ b/Corale.Colore.Tester/App.xaml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/Corale.Colore.Tester/App.xaml.cs b/Corale.Colore.Tester/App.xaml.cs new file mode 100644 index 00000000..992341de --- /dev/null +++ b/Corale.Colore.Tester/App.xaml.cs @@ -0,0 +1,34 @@ +// --------------------------------------------------------------------------------------- +// +// Copyright © 2015 by Adam Hellberg and Brandon Scott. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// "Razer" is a trademark of Razer USA Ltd. +// +// --------------------------------------------------------------------------------------- + +namespace Corale.Colore.Tester +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App + { + } +} diff --git a/Corale.Colore.Tester/Classes/DelegateCommand.cs b/Corale.Colore.Tester/Classes/DelegateCommand.cs new file mode 100644 index 00000000..656de06b --- /dev/null +++ b/Corale.Colore.Tester/Classes/DelegateCommand.cs @@ -0,0 +1,54 @@ +// --------------------------------------------------------------------------------------- +// +// Copyright © 2015 by Adam Hellberg and Brandon Scott. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// "Razer" is a trademark of Razer USA Ltd. +// +// --------------------------------------------------------------------------------------- + +namespace Corale.Colore.Tester.Classes +{ + using System; + using System.Windows.Input; + + public class DelegateCommand : ICommand + { + public DelegateCommand(Action action) + { + CommandAction = action; + } + +#pragma warning disable CS0067 + public event EventHandler CanExecuteChanged; +#pragma warning restore CS0067 + + public Action CommandAction { get; } + + public void Execute(object parameter) + { + CommandAction(); + } + + public bool CanExecute(object parameter) + { + return true; + } + } +} diff --git a/Corale.Colore.Tester/Corale.Colore.Tester.csproj b/Corale.Colore.Tester/Corale.Colore.Tester.csproj new file mode 100644 index 00000000..6fa3157d --- /dev/null +++ b/Corale.Colore.Tester/Corale.Colore.Tester.csproj @@ -0,0 +1,167 @@ + + + + + Debug + AnyCPU + {C9F94917-DB10-492E-8CCE-2F8A05D34CAF} + WinExe + Properties + Corale.Colore.Tester + Corale.Colore.Tester + v4.0 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + ..\Corale.Colore.ruleset + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + ..\Corale.Colore.ruleset + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + prompt + ..\Corale.Colore.ruleset + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + ..\Corale.Colore.ruleset + + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + ..\Corale.Colore.ruleset + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + prompt + ..\Corale.Colore.ruleset + + + + + + + + + + + 4.0 + + + + + + ..\packages\Extended.Wpf.Toolkit.2.5\lib\net40\Xceed.Wpf.Toolkit.dll + True + + + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + + + + + + + + + + + MainWindow.xaml + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + stylecop.json + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + Designer + MSBuild:Compile + + + + + {5fe57efb-ef8f-4c1b-8c13-0f85f3befffa} + Corale.Colore + + + + + + + + + + \ No newline at end of file diff --git a/Corale.Colore.Tester/Corale.Colore.Tester.csproj.DotSettings b/Corale.Colore.Tester/Corale.Colore.Tester.csproj.DotSettings new file mode 100644 index 00000000..73e96563 --- /dev/null +++ b/Corale.Colore.Tester/Corale.Colore.Tester.csproj.DotSettings @@ -0,0 +1,2 @@ + + CSharp60 \ No newline at end of file diff --git a/Corale.Colore.Tester/GlobalSuppressions.cs b/Corale.Colore.Tester/GlobalSuppressions.cs new file mode 100644 index 00000000..57e3ffee --- /dev/null +++ b/Corale.Colore.Tester/GlobalSuppressions.cs @@ -0,0 +1,24 @@ +// +// Copyright © 2015 by Adam Hellberg and Brandon Scott. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// "Razer" is a trademark of Razer USA Ltd. +// + +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1652:Enable XML documentation output", Justification = "Tests don't need docs")] diff --git a/Corale.Colore.Tester/MainWindow.xaml b/Corale.Colore.Tester/MainWindow.xaml new file mode 100644 index 00000000..82fb687e --- /dev/null +++ b/Corale.Colore.Tester/MainWindow.xaml @@ -0,0 +1,403 @@ + + + + + + + + + + + + + + + +