├── .gitignore
├── .nuget
├── NuGet.Config
├── NuGet.exe
└── NuGet.targets
├── .travis.yml
├── CHANGELOG.md
├── Destinations
└── NBug.Destinations.AzureBlobStorage
│ ├── AzureBlobStorage.cs
│ ├── AzureBlobStorageFactory.cs
│ ├── NBug.Destinations.AzureBlobStorage.csproj
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── Signing.snk
│ └── packages.config
├── Documentation
├── Documentation.csproj
├── chm
│ └── NBug 1.1.1 Docs.chm
└── html
│ ├── content
│ ├── blank.html
│ └── getting_started.html
│ ├── index.html
│ └── toc.html
├── Examples
├── NBug.Examples.Console
│ ├── NBug.Examples.Console.csproj
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── app.config
├── NBug.Examples.WPF
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ ├── NBug.Examples.WPF.csproj
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ └── app.config
└── NBug.Examples.WinForms
│ ├── MainForm.Designer.cs
│ ├── MainForm.cs
│ ├── MainForm.resx
│ ├── NBug.Examples.WinForms.csproj
│ ├── Normal.Designer.cs
│ ├── Normal.cs
│ ├── Normal.resx
│ ├── Program.cs
│ ├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
│ └── app.config
├── GlobalAssemblyInfo.cs
├── LICENSE.md
├── NBug.Configurator
├── AboutBox.Designer.cs
├── AboutBox.cs
├── AboutBox.resx
├── CustomPreviewForm.Designer.cs
├── CustomPreviewForm.cs
├── CustomPreviewForm.resx
├── MainForm.Designer.cs
├── MainForm.cs
├── MainForm.resx
├── NBug.Configurator.csproj
├── PreviewForm.Designer.cs
├── PreviewForm.cs
├── PreviewForm.resx
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── SubmitPanels
│ ├── Custom
│ │ ├── Custom.Designer.cs
│ │ ├── Custom.cs
│ │ └── Custom.resx
│ ├── ISubmitPanel.cs
│ ├── PanelLoader.Designer.cs
│ ├── PanelLoader.cs
│ ├── PanelLoader.resx
│ ├── Tracker
│ │ ├── Mantis.Designer.cs
│ │ ├── Mantis.cs
│ │ ├── Mantis.resx
│ │ ├── Redmine.Designer.cs
│ │ ├── Redmine.cs
│ │ └── Redmine.resx
│ └── Web
│ │ ├── Ftp.Designer.cs
│ │ ├── Ftp.cs
│ │ ├── Ftp.resx
│ │ ├── Http.Designer.cs
│ │ ├── Http.cs
│ │ ├── Http.resx
│ │ ├── Mail.Designer.cs
│ │ ├── Mail.cs
│ │ └── Mail.resx
├── app.config
└── resources
│ ├── AboutBox.png
│ ├── Icon.png
│ ├── Icon_16.png
│ ├── help.png
│ ├── run.png
│ └── save.png
├── NBug.Tests
├── Functional
│ ├── DeveloperUITests.cs
│ ├── SettingsUITests.cs
│ └── WinFormsUITests.cs
├── Integration
│ ├── BugReportTests.cs
│ ├── DispatcherTests.cs
│ ├── HandlerTests.cs
│ └── SettingsTests.cs
├── NBug.Tests.csproj
├── Properties
│ └── AssemblyInfo.cs
├── Tools
│ ├── Extensions
│ │ └── UIAttribute.cs
│ ├── Fixtures
│ │ ├── ReportFixture.cs
│ │ ├── SettingsFixture.cs
│ │ └── UIFixture.cs
│ └── Stubs
│ │ ├── DummyArgumentException.cs
│ │ └── DummySerializableException.cs
├── Unit
│ ├── BugReportTests.cs
│ └── Helpers
│ │ └── EmailDestinationBuilderTests.cs
└── packages.config
├── NBug.sln
├── NBug
├── Core
│ ├── Reporting
│ │ ├── BugReport.cs
│ │ ├── Feedback.cs
│ │ ├── Info
│ │ │ ├── AssemblyInfo.cs
│ │ │ ├── ConfigurationInfo.cs
│ │ │ ├── GeneralInfo.cs
│ │ │ ├── Report.cs
│ │ │ └── SystemInfo.cs
│ │ └── MiniDump
│ │ │ ├── DumpTypeFlag.cs
│ │ │ ├── DumpWriter.cs
│ │ │ └── ExceptionFilters.cs
│ ├── Submission
│ │ ├── Custom
│ │ │ └── Custom.cs
│ │ ├── Database
│ │ │ ├── Ado.cs
│ │ │ ├── MsSql.cs
│ │ │ └── MySql.cs
│ │ ├── Dispatcher.cs
│ │ ├── IProtocol.cs
│ │ ├── IProtocolFactory.cs
│ │ ├── ProtocolBase.cs
│ │ ├── Protocols.cs
│ │ ├── Tracker
│ │ │ ├── BugNet.cs
│ │ │ ├── Bugzilla.cs
│ │ │ ├── GitHub.cs
│ │ │ ├── GoogleCode.cs
│ │ │ ├── Mantis
│ │ │ │ ├── AccountData.cs
│ │ │ │ ├── AttachmentData.cs
│ │ │ │ ├── CustomFieldValueForIssueData.cs
│ │ │ │ ├── IMantisConnectService.cs
│ │ │ │ ├── IssueData.cs
│ │ │ │ ├── IssueNoteData.cs
│ │ │ │ ├── Mantis.cs
│ │ │ │ ├── MantisConnectService.cs
│ │ │ │ ├── ObjectRef.cs
│ │ │ │ ├── ProjectVersionData.cs
│ │ │ │ ├── RelationshipData.cs
│ │ │ │ ├── UserData.cs
│ │ │ │ └── nusoap.php.patch
│ │ │ ├── Redmine.cs
│ │ │ └── Trac.cs
│ │ └── Web
│ │ │ ├── Ftp.cs
│ │ │ ├── Http.cs
│ │ │ └── Mail.cs
│ ├── UI
│ │ ├── Console
│ │ │ └── ConsoleUI.cs
│ │ ├── Custom
│ │ │ └── CustomUI.cs
│ │ ├── Developer
│ │ │ ├── InternalExceptionViewer.Designer.cs
│ │ │ ├── InternalExceptionViewer.cs
│ │ │ ├── InternalExceptionViewer.resx
│ │ │ ├── InternalLogViewer.Designer.cs
│ │ │ ├── InternalLogViewer.cs
│ │ │ └── InternalLogViewer.resx
│ │ ├── UIDialogResult.cs
│ │ ├── UISelector.cs
│ │ ├── WPF
│ │ │ └── WPFUI.cs
│ │ └── WinForms
│ │ │ ├── Feedback.Designer.cs
│ │ │ ├── Feedback.cs
│ │ │ ├── Feedback.resx
│ │ │ ├── Full.Designer.cs
│ │ │ ├── Full.cs
│ │ │ ├── Full.resx
│ │ │ ├── Minimal.cs
│ │ │ ├── Normal.Designer.cs
│ │ │ ├── Normal.cs
│ │ │ ├── Normal.resx
│ │ │ ├── Panels
│ │ │ ├── ExceptionDetailView.Designer.cs
│ │ │ ├── ExceptionDetailView.cs
│ │ │ ├── ExceptionDetailView.resx
│ │ │ ├── ExceptionDetails.Designer.cs
│ │ │ ├── ExceptionDetails.cs
│ │ │ └── ExceptionDetails.resx
│ │ │ └── WinFormsUI.cs
│ └── Util
│ │ ├── ConnectionStringParser.cs
│ │ ├── ExceptionThread.cs
│ │ ├── Exceptions
│ │ ├── NBugConfigurationException.cs
│ │ ├── NBugException.cs
│ │ └── NBugRuntimeException.cs
│ │ ├── Logging
│ │ └── Logger.cs
│ │ ├── ProtectedConfiguration.cs
│ │ ├── PublicResources.cs
│ │ ├── Serialization
│ │ ├── SerializableDictionary.cs
│ │ └── SerializableException.cs
│ │ ├── Storage
│ │ ├── FileMask.cs
│ │ ├── StoragePath.cs
│ │ ├── StoredItemFile.cs
│ │ ├── Storer.cs
│ │ └── ZipStorer.cs
│ │ └── Web
│ │ └── StreamUpload.cs
├── Enums
│ ├── LoggerCategory.cs
│ ├── MiniDumpType.cs
│ ├── StoragePath.cs
│ ├── UIMode.cs
│ └── UIProvider.cs
├── Events
│ ├── CustomSubmissionEventArgs.cs
│ └── CustomUIEventArgs.cs
├── Exceptions.cs
├── Handler.cs
├── Helpers
│ └── EmailDestinationBuilder.cs
├── NBug.csproj
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Localization.Designer.cs
│ ├── Localization.de.Designer.cs
│ ├── Localization.de.resx
│ ├── Localization.es-MX.Designer.cs
│ ├── Localization.es-MX.resx
│ ├── Localization.fi-FI.Designer.cs
│ ├── Localization.fi-FI.resx
│ ├── Localization.hr.Designer.cs
│ ├── Localization.hr.resx
│ ├── Localization.ja.Designer.cs
│ ├── Localization.ja.resx
│ ├── Localization.ko-KR.Designer.cs
│ ├── Localization.ko-KR.resx
│ ├── Localization.nl.Designer.cs
│ ├── Localization.nl.resx
│ ├── Localization.pl-PL.Designer.cs
│ ├── Localization.pl-PL.resx
│ ├── Localization.pt-BR.Designer.cs
│ ├── Localization.pt-BR.resx
│ ├── Localization.resx
│ ├── Localization.ru-RU.Designer.cs
│ ├── Localization.ru-RU.resx
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ ├── Settings.settings
│ └── SettingsOverride.cs
├── Settings.cs
├── app.config
└── resources
│ ├── Error_16.png
│ ├── Feedback.png
│ ├── Forum_16.png
│ ├── Help_16.png
│ ├── NBug_Icon_PNG_16.png
│ ├── NBug_icon_16.ico
│ ├── NBug_icon_16_borders.ico
│ ├── Send.png
│ ├── VS2010_16.png
│ └── icon.ico
├── README.md
├── Settings.StyleCop
└── Signing.snk
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.sln.docstates
8 |
9 | # Build results
10 |
11 | [Dd]ebug*/
12 | [Rr]elease/
13 |
14 | build/
15 |
16 |
17 | [Tt]est[Rr]esult
18 | [Bb]uild[Ll]og.*
19 |
20 | *_i.c
21 | *_p.c
22 | *.ilk
23 | *.meta
24 | *.obj
25 | *.pch
26 | *.pdb
27 | *.pgc
28 | *.pgd
29 | *.rsp
30 | *.sbr
31 | *.tlb
32 | *.tli
33 | *.tlh
34 | *.tmp
35 | *.vspscc
36 | *.vssscc
37 | .builds
38 |
39 | *.pidb
40 |
41 | *.log
42 | *.scc
43 | # Visual C++ cache files
44 | ipch/
45 | *.aps
46 | *.ncb
47 | *.opensdf
48 | *.sdf
49 |
50 | # Visual Studio profiler
51 | *.psess
52 | *.vsp
53 |
54 | # Guidance Automation Toolkit
55 | *.gpState
56 |
57 | # ReSharper is a .NET coding add-in
58 | _ReSharper*/
59 |
60 | *.[Rr]e[Ss]harper
61 |
62 | # NCrunch
63 | *.ncrunch*
64 | .*crunch*.local.xml
65 |
66 | # Installshield output folder
67 | [Ee]xpress
68 |
69 | # DocProject is a documentation generator add-in
70 | DocProject/buildhelp/
71 | DocProject/Help/*.HxT
72 | DocProject/Help/*.HxC
73 | DocProject/Help/*.hhc
74 | DocProject/Help/*.hhk
75 | DocProject/Help/*.hhp
76 | DocProject/Help/Html2
77 | DocProject/Help/html
78 |
79 | # Click-Once directory
80 | publish
81 |
82 | # Publish Web Output
83 | *.Publish.xml
84 |
85 | # Others
86 | [Bb]in
87 | [Oo]bj
88 | sql
89 | TestResults
90 | [Tt]est[Rr]esult*
91 | *.Cache
92 | ClientBin
93 | [Ss]tyle[Cc]op.*
94 | ~$*
95 | *.dbmdl
96 |
97 | *.[Pp]ublish.xml
98 |
99 | Generated_Code #added for RIA/Silverlight projects
100 |
101 | # Backup & report files from converting an old project file to a newer
102 | # Visual Studio version. Backup files are not needed, because we have git ;-)
103 | _UpgradeReport_Files/
104 | Backup*/
105 | UpgradeLog*.XML
106 |
107 | # NuGet
108 | packages/
109 |
110 | # MonoDevelop
111 | NBug.userprefs
112 |
--------------------------------------------------------------------------------
/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: csharp
2 | solution: NBug.sln
3 | install:
4 | - nuget restore NBug.sln
5 | - nuget install xunit.runners -Version 1.9.0.1566 -OutputDirectory testrunner
6 | script:
7 | - xbuild /p:Configuration=Release NBug.sln
8 | - mono ./testrunner/xunit.runners.1.9.0.1566/tools/xunit.console.clr4.exe ./NBug.Tests/bin/Release/NBug.Tests.dll
9 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # TBD
2 |
3 | * Ability to send bug reports immediately.
4 | * Improve ability to attach extra files to bug report.
5 | * Now builds on Mono.
6 | * Handle invalid/corrupt report files gracefully.
7 | * Exception report sent to the developer is always in English rather than user's language.
8 |
9 | # 1.2.2
10 |
11 | *November 16, 2013*
12 |
13 | * More elaborate fixes for serialization problems.
14 | * Fixes for memory dump issues.
15 |
16 | # 1.2.1
17 |
18 | *November 13, 2013*
19 |
20 | * Fix for exception serialization bug.
21 |
22 | # 1.2
23 |
24 | *November 9, 2013*
25 |
26 | * Bug fixes for Web apps.
27 | * Added more localizations.
28 | * Custom error reporting and attachments are now possible.
29 |
30 | # 1.1
31 |
32 | *July 2, 2011*
33 |
34 | * Tons of bug fixes and stability improvements. Library is rock solid now and is in production with some great apps.
35 | * Added exception filters.
36 |
37 | # 1.0
38 |
39 | *March 1, 2011*
40 |
41 | * Initial release of NBug.
42 |
--------------------------------------------------------------------------------
/Destinations/NBug.Destinations.AzureBlobStorage/AzureBlobStorage.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Destinations.AzureBlobStorage
8 | {
9 | using System;
10 | using System.IO;
11 |
12 | using Microsoft.WindowsAzure.Storage.Auth;
13 | using Microsoft.WindowsAzure.Storage.Blob;
14 |
15 | using NBug.Core.Reporting.Info;
16 | using NBug.Core.Submission;
17 | using NBug.Core.Util.Serialization;
18 |
19 | public class AzureBlobStorage : ProtocolBase
20 | {
21 | public AzureBlobStorage(string connectionString)
22 | : base(connectionString)
23 | {
24 | }
25 |
26 | public string AccountName { get; set; }
27 |
28 | public string ContainerName { get; set; }
29 |
30 | public string SharedAccessSignature { get; set; }
31 |
32 | // Connection string format (single line)
33 | // Warning: There should be no semicolon (;) or equals sign (=) used in any field except for password.
34 | // Warning: No field value value should contain the phrase 'password='
35 | // Note: SharedAccessUrl must be Uri.EscapeDataString()'ed
36 |
37 | /* Type=AzureBlobStorage;
38 | * AccountName=youraccountname;
39 | * ContainerName=yourcontainername;
40 | * SharedAccessSignature=sr%3Dc%26si%3D16dacb22-asdf-asdf-asdf-e58fasdff3ed%26se%3D2098-12-31T23%253A00%253A00Z%26sig%3asdfIWtlasdfb98q0Kidp%252BasdffJcRm1ulFIjyks4E%253D
41 | */
42 | public override bool Send(string fileName, Stream file, Report report, SerializableException exception)
43 | {
44 | var cred = new StorageCredentials(Uri.UnescapeDataString(this.SharedAccessSignature));
45 |
46 | var blobUrl = new Uri(string.Format("https://{0}.blob.core.windows.net/{1}", this.AccountName, this.ContainerName));
47 | var container = new CloudBlobContainer(blobUrl, cred);
48 |
49 | var blob = container.GetBlockBlobReference(fileName);
50 |
51 | file.Position = 0;
52 | blob.UploadFromStream(file);
53 | return true;
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/Destinations/NBug.Destinations.AzureBlobStorage/AzureBlobStorageFactory.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Destinations.AzureBlobStorage
8 | {
9 | using NBug.Core.Submission;
10 |
11 | public class AzureBlobStorageFactory : IProtocolFactory
12 | {
13 | public string SupportedType
14 | {
15 | get
16 | {
17 | return "AzureBlobStorage";
18 | }
19 | }
20 |
21 | public IProtocol FromConnectionString(string connectionString)
22 | {
23 | return new AzureBlobStorage(connectionString);
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/Destinations/NBug.Destinations.AzureBlobStorage/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 |
8 |
9 | using System.Reflection;
10 | using System.Runtime.InteropServices;
11 |
12 | // General Information about an assembly is controlled through the following
13 | // set of attributes. Change these attribute values to modify the information
14 | // associated with an assembly.
15 | [assembly: AssemblyTitle("NBug.Destinations.AzureBlobStorage")]
16 | [assembly: AssemblyDescription("")]
17 | [assembly: AssemblyConfiguration("")]
18 | [assembly: AssemblyCompany("")]
19 | [assembly: AssemblyProduct("NBug.Destinations.AzureBlobStorage")]
20 | [assembly: AssemblyCopyright("Copyright © 2013")]
21 | [assembly: AssemblyTrademark("")]
22 | [assembly: AssemblyCulture("")]
23 |
24 | // Setting ComVisible to false makes the types in this assembly not visible
25 | // to COM components. If you need to access a type in this assembly from
26 | // COM, set the ComVisible attribute to true on that type.
27 | [assembly: ComVisible(false)]
28 |
29 | // The following GUID is for the ID of the typelib if this project is exposed to COM
30 | [assembly: Guid("76a52bbd-f3e7-4a18-9ca8-f506e6e4e9c4")]
31 |
32 | // Version information for an assembly consists of the following four values:
33 | // Major Version
34 | // Minor Version
35 | // Build Number
36 | // Revision
37 | // You can specify all the values or you can default the Build and Revision Numbers
38 | // by using the '*' as shown below:
39 | // [assembly: AssemblyVersion("1.0.*")]
40 | [assembly: AssemblyVersion("1.0.0.0")]
41 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/Destinations/NBug.Destinations.AzureBlobStorage/Signing.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/Destinations/NBug.Destinations.AzureBlobStorage/Signing.snk
--------------------------------------------------------------------------------
/Destinations/NBug.Destinations.AzureBlobStorage/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Documentation/chm/NBug 1.1.1 Docs.chm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/Documentation/chm/NBug 1.1.1 Docs.chm
--------------------------------------------------------------------------------
/Documentation/html/content/blank.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Documentation/html/content/getting_started.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Documentation/html/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | NBug Documentation
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Documentation/html/toc.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Untitled Page
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Examples/NBug.Examples.Console/Program.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Examples.Console
8 | {
9 | using System;
10 | using System.IO;
11 | using System.Threading.Tasks;
12 |
13 | using NBug.Properties;
14 |
15 | public class Program
16 | {
17 | public static void Main(string[] args)
18 | {
19 | // Check to see if test application is initialized by the configurator tool
20 | if (args.Length > 0)
21 | {
22 | var stream = new FileStream(args[0], FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
23 | SettingsOverride.LoadCustomSettings(stream);
24 | }
25 |
26 | // Sample NBug configuration for console applications
27 | AppDomain.CurrentDomain.UnhandledException += Handler.UnhandledException;
28 | TaskScheduler.UnobservedTaskException += Handler.UnobservedTaskException;
29 |
30 | Console.WriteLine("NBug now auto-handles: AppDomain.CurrentDomain.UnhandledException");
31 | Console.WriteLine("NBug now auto-handles: Threading.Tasks.TaskScheduler.UnobservedTaskException");
32 | Console.WriteLine(Environment.NewLine);
33 | Console.Write("Generate a System.Exception (y/n): ");
34 |
35 | if (Console.ReadKey().Key == ConsoleKey.Y)
36 | {
37 | throw new Exception("This is an exception thrown from NBug console sample application.");
38 | }
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/Examples/NBug.Examples.Console/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 |
8 |
9 | using System.Reflection;
10 | using System.Runtime.InteropServices;
11 |
12 | // General Information about an assembly is controlled through the following
13 | // set of attributes. Change these attribute values to modify the information
14 | // associated with an assembly.
15 | [assembly: AssemblyTitle("NBug.Examples.Console")]
16 | [assembly: AssemblyDescription("NBug Console Sample Application created by Teoman Soygul.")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | // The following GUID is for the ID of the typelib if this project is exposed to COM
25 | [assembly: Guid("9e72b2e3-590a-4ffe-8de5-ffa37efc9dd6")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | // Major Version
29 | // Minor Version
30 | // Build Number
31 | // Revision
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
--------------------------------------------------------------------------------
/Examples/NBug.Examples.Console/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Examples/NBug.Examples.WPF/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Examples/NBug.Examples.WPF/App.xaml.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Examples.WPF
8 | {
9 | using System;
10 | using System.IO;
11 | using System.Linq;
12 | using System.Threading.Tasks;
13 | using System.Windows;
14 |
15 | using NBug.Properties;
16 |
17 | ///
18 | /// Interaction logic for App.xaml
19 | ///
20 | public partial class App : Application
21 | {
22 | public App()
23 | {
24 | // Check to see if test application is initialized by the configurator tool
25 | if (Environment.GetCommandLineArgs().Count() > 1)
26 | {
27 | var stream = new FileStream(Environment.GetCommandLineArgs()[1], FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
28 | SettingsOverride.LoadCustomSettings(stream);
29 | }
30 |
31 | // For demonstrational purposes only, normally this should be left with it's default value as false!
32 | Settings.HandleProcessCorruptedStateExceptions = true;
33 |
34 | // Sample NBug configuration for WPF applications
35 | AppDomain.CurrentDomain.UnhandledException += Handler.UnhandledException;
36 | Current.DispatcherUnhandledException += Handler.DispatcherUnhandledException;
37 | TaskScheduler.UnobservedTaskException += Handler.UnobservedTaskException;
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/Examples/NBug.Examples.WPF/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 |
10 |
11 |
12 |
13 |
14 |
15 |
17 |
18 |
--------------------------------------------------------------------------------
/Examples/NBug.Examples.WPF/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | using System.Diagnostics;
8 | using NBug.Events;
9 |
10 | namespace NBug.Examples.WPF
11 | {
12 | using System;
13 | using System.Threading;
14 | using System.Threading.Tasks;
15 | using System.Windows;
16 |
17 | ///
18 | /// Interaction logic for MainWindow.xaml
19 | ///
20 | public partial class MainWindow : Window
21 | {
22 | public MainWindow()
23 | {
24 | this.InitializeComponent();
25 |
26 | //we want to display custom dialog to the user when bug occurs (optional)
27 | Settings.CustomUIEvent += this.Settings_CustomUIEvent;
28 |
29 | //we want to add custom submission processing to our application (optional)
30 | Settings.CustomSubmissionEvent += Settings_CustomSubmissionEvent;
31 |
32 | this.crashTypeComboBox.SelectedIndex = 0;
33 | }
34 |
35 | private unsafe void AccessViolation()
36 | {
37 | var b = *(byte*)8762765876;
38 | }
39 |
40 | private void CloseButton_Click(object sender, RoutedEventArgs e)
41 | {
42 | this.Close();
43 | }
44 |
45 | private void CrashButton_Click(object sender, RoutedEventArgs e)
46 | {
47 | switch (this.crashTypeComboBox.Text)
48 | {
49 | case "UI Thread: System.Exception":
50 | throw new Exception("Selected exception: '" + this.crashTypeComboBox.Text + "' was thrown.");
51 | case "UI Thread: System.ArgumentException":
52 | throw new ArgumentException("Selected exception: '" + this.crashTypeComboBox.Text + "' was thrown.", "MyInvalidParameter");
53 | case "Background Thread (Task): System.Exception":
54 | Task.Factory.StartNew(() => { throw new Exception(); });
55 |
56 | // Below code makes sure that exception is thrown as only after finalization, the aggregateexception is thrown.
57 | // As a side affect, unlike the normal behavior, the applicaiton will note continue its execution but will shut
58 | // down just like any main thread exceptions, even if there is no handle to UnobservedTaskException!
59 | // So remove below 3 lines to observe the normal continuation behavior.
60 | Thread.Sleep(200);
61 | GC.Collect();
62 | GC.WaitForPendingFinalizers();
63 | break;
64 | case "Process Corrupted State Exception: Access Violation":
65 | Settings.HandleProcessCorruptedStateExceptions = true;
66 | this.AccessViolation();
67 | break;
68 | }
69 | }
70 |
71 | ///
72 | /// Handles CustomUIEvent to show custom dialog when bug has occured
73 | ///
74 | ///
75 | ///
76 | private void Settings_CustomUIEvent(object sender, CustomUIEventArgs e)
77 | {
78 | MessageBox.Show(e.Exception.Message, "Custom Dialog", MessageBoxButton.OK, MessageBoxImage.Error);
79 | }
80 |
81 | ///
82 | /// Handles CustomSubmissionEvent to submit bug
83 | ///
84 | ///
85 | ///
86 | void Settings_CustomSubmissionEvent(object sender, CustomSubmissionEventArgs e)
87 | {
88 | Debug.WriteLine(string.Format("Custom submission for exception {0}", e.Exception.Message));
89 | e.Result = true;
90 | }
91 | }
92 | }
--------------------------------------------------------------------------------
/Examples/NBug.Examples.WPF/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 |
8 |
9 | using System.Reflection;
10 | using System.Runtime.InteropServices;
11 | using System.Windows;
12 |
13 | // General Information about an assembly is controlled through the following
14 | // set of attributes. Change these attribute values to modify the information
15 | // associated with an assembly.
16 | [assembly: AssemblyTitle("NBug.Examples.WPF")]
17 | [assembly: AssemblyDescription("NBug WPF Sample Application created by Teoman Soygul.")]
18 | [assembly: AssemblyCulture("")]
19 |
20 | // Setting ComVisible to false makes the types in this assembly not visible
21 | // to COM components. If you need to access a type in this assembly from
22 | // COM, set the ComVisible attribute to true on that type.
23 | [assembly: ComVisible(false)]
24 |
25 | //In order to begin building localizable applications, set
26 | //CultureYouAreCodingWith in your .csproj file
27 | //inside a . For example, if you are using US english
28 | //in your source files, set the to en-US. Then uncomment
29 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
30 | //the line below to match the UICulture setting in the project file.
31 |
32 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
33 | [assembly: ThemeInfo(ResourceDictionaryLocation.None, // where theme specific resource dictionaries are located
34 | // (used if a resource is not found in the page,
35 | // or application resource dictionaries)
36 | ResourceDictionaryLocation.SourceAssembly // where the generic resource dictionary is located
37 | // (used if a resource is not found in the page,
38 | // app, or any theme specific resource dictionaries)
39 | )]
--------------------------------------------------------------------------------
/Examples/NBug.Examples.WPF/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.225
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace NBug.Examples.WPF.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NBug.Examples.WPF.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Examples/NBug.Examples.WPF/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.225
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace NBug.Examples.WPF.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Examples/NBug.Examples.WPF/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Examples/NBug.Examples.WPF/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Examples/NBug.Examples.WinForms/MainForm.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | using System.Diagnostics;
8 |
9 | namespace NBug.Examples.WinForms
10 | {
11 | using System;
12 | using System.Threading;
13 | using System.Threading.Tasks;
14 | using System.Windows.Forms;
15 |
16 | using NBug.Events;
17 |
18 | public partial class MainForm : Form
19 | {
20 | public MainForm()
21 | {
22 | this.InitializeComponent();
23 |
24 | //we want to display custom dialog to the user when bug occurs (optional)
25 | Settings.CustomUIEvent += this.Settings_CustomUIEvent;
26 |
27 | //we want to add custom submission processing to our application (optional)
28 | Settings.CustomSubmissionEvent += Settings_CustomSubmissionEvent;
29 |
30 | this.crashTypeComboBox.SelectedIndex = 0;
31 | }
32 |
33 | private unsafe void AccessViolation()
34 | {
35 | var b = *(byte*)8762765876;
36 | }
37 |
38 | private void CloseButton_Click(object sender, EventArgs e)
39 | {
40 | this.Close();
41 | }
42 |
43 | private void CrashButton_Click(object sender, EventArgs e)
44 | {
45 | switch (this.crashTypeComboBox.Text)
46 | {
47 | case "UI Thread: System.Exception":
48 | throw new Exception("Selected exception: '" + this.crashTypeComboBox.Text + "' was thrown.");
49 | case "UI Thread: System.ArgumentException":
50 | throw new ArgumentException(
51 | "Selected exception: '" + this.crashTypeComboBox.Text + "' was thrown.",
52 | "MyInvalidParameter",
53 | new Exception("Test inner exception for argument exception."));
54 | case "Background Thread (Task): System.Exception":
55 | Task.Factory.StartNew(() => { throw new Exception(); });
56 |
57 | // Below code makes sure that exception is thrown as only after finalization, the aggregateexception is thrown.
58 | // As a side affect, unlike the normal behavior, the applicaiton will note continue its execution but will shut
59 | // down just like any main thread exceptions, even if there is no handle to UnobservedTaskException!
60 | // So remove below 3 lines to observe the normal continuation behavior.
61 | Thread.Sleep(200);
62 | GC.Collect();
63 | GC.WaitForPendingFinalizers();
64 | break;
65 | case "Process Corrupted State Exception: Access Violation":
66 | this.AccessViolation();
67 | break;
68 | }
69 | }
70 |
71 | ///
72 | /// Handles CustomUIEvent to show custom dialog when bug has occured
73 | ///
74 | ///
75 | ///
76 | private void Settings_CustomUIEvent(object sender, CustomUIEventArgs e)
77 | {
78 | var Form = new Normal();
79 | e.Result = Form.ShowDialog(e.Report);
80 | }
81 |
82 | ///
83 | /// Handles CustomSubmissionEvent to submit bug
84 | ///
85 | ///
86 | ///
87 | void Settings_CustomSubmissionEvent(object sender, CustomSubmissionEventArgs e)
88 | {
89 | Debug.WriteLine(string.Format("Custom submission for exception {0}", e.Exception.Message));
90 | e.Result = true;
91 | }
92 | }
93 | }
--------------------------------------------------------------------------------
/Examples/NBug.Examples.WinForms/Normal.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Examples.WinForms
8 | {
9 | using System;
10 | using System.Windows.Forms;
11 |
12 | using NBug.Core.Reporting.Info;
13 | using NBug.Core.UI;
14 |
15 | internal partial class Normal : Form
16 | {
17 | private UIDialogResult uiDialogResult;
18 |
19 | internal Normal()
20 | {
21 | this.InitializeComponent();
22 | }
23 |
24 | internal UIDialogResult ShowDialog(Report report)
25 | {
26 | this.Text = string.Format("{0} CustomUI {1}", report.GeneralInfo.HostApplication, Settings.Resources.UI_Dialog_Normal_Title);
27 | this.exceptionMessageLabel.Text = report.GeneralInfo.ExceptionMessage;
28 |
29 | this.ShowDialog();
30 |
31 | return this.uiDialogResult;
32 | }
33 |
34 | private void ContinueButton_Click(object sender, EventArgs e)
35 | {
36 | this.uiDialogResult = new UIDialogResult(ExecutionFlow.ContinueExecution, SendReport.Send);
37 | this.Close();
38 | }
39 |
40 | private void QuitButton_Click(object sender, EventArgs e)
41 | {
42 | this.uiDialogResult = new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send);
43 | this.Close();
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/Examples/NBug.Examples.WinForms/Program.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Examples.WinForms
8 | {
9 | using System;
10 | using System.IO;
11 | using System.Linq;
12 | using System.Threading.Tasks;
13 | using System.Windows.Forms;
14 |
15 | using NBug.Properties;
16 |
17 | public static class Program
18 | {
19 | ///
20 | /// The main entry point for the application.
21 | ///
22 | [STAThread]
23 | public static void Main()
24 | {
25 | // Check to see if test application is initialized by the configurator tool
26 | if (Environment.GetCommandLineArgs().Count() > 1)
27 | {
28 | var stream = new FileStream(Environment.GetCommandLineArgs()[1], FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
29 | SettingsOverride.LoadCustomSettings(stream);
30 | }
31 |
32 | // For demonstrational purposes only, normally this should be left with it's default value as false!
33 | Settings.HandleProcessCorruptedStateExceptions = true;
34 |
35 | // Sample NBug configuration for WinForms applications
36 | AppDomain.CurrentDomain.UnhandledException += Handler.UnhandledException;
37 | Application.ThreadException += Handler.ThreadException;
38 | TaskScheduler.UnobservedTaskException += Handler.UnobservedTaskException;
39 |
40 | Application.EnableVisualStyles();
41 | Application.SetCompatibleTextRenderingDefault(false);
42 | Application.Run(new MainForm());
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/Examples/NBug.Examples.WinForms/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 |
8 |
9 | using System.Reflection;
10 | using System.Runtime.InteropServices;
11 |
12 | // General Information about an assembly is controlled through the following
13 | // set of attributes. Change these attribute values to modify the information
14 | // associated with an assembly.
15 | [assembly: AssemblyTitle("NBug.Examples.WinForms")]
16 | [assembly: AssemblyDescription("NBug Test Application created by Teoman Soygul.")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | // The following GUID is for the ID of the typelib if this project is exposed to COM
25 | [assembly: Guid("a253ce3b-ee68-4aec-958d-c285a61c8fc3")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | // Major Version
29 | // Minor Version
30 | // Build Number
31 | // Revision
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
--------------------------------------------------------------------------------
/Examples/NBug.Examples.WinForms/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.225
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace NBug.Examples.WinForms.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NBug.Examples.WinForms.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Examples/NBug.Examples.WinForms/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.225
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace NBug.Examples.WinForms.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Examples/NBug.Examples.WinForms/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Examples/NBug.Examples.WinForms/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/GlobalAssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | using System;
8 | using System.Reflection;
9 |
10 | // General Information about an assembly is controlled through the following
11 | // set of attributes. Change these attribute values to modify the information
12 | // associated with an assembly.
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("NBug")]
15 | [assembly: AssemblyCopyright("Copyright © 2013 Teoman Soygul")]
16 | [assembly: AssemblyTrademark("")]
17 | #if DEBUG
18 |
19 | [assembly: AssemblyConfiguration("Debug")]
20 | #else
21 | [assembly: AssemblyConfiguration("Release")]
22 | #endif
23 |
24 | /*
25 | * Basic rules to become CLS compilant is below:
26 | * 1. Unsigned types should not be part of the public interface of the class. What this means is public fields should not
27 | * have unsigned types like uint or ulong, public methods should not return unsigned types, parameters passed to public
28 | * function should not have unsigned types. However unsigned types can be part of private members.
29 | * 2. Unsafe types like pointers should not be used with public members. However they can be used with private members.
30 | * 3. Class names and member names should not differ only based on their case. For example we cannot have two methods
31 | * named MyMethod and MYMETHOD.
32 | * 4. Only properties and methods may be overloaded, Operators should not be overloaded.
33 | */
34 | [assembly: CLSCompliant(true)]
35 |
36 | // Version information for an assembly consists of the following four values:
37 | // Major Version
38 | // Minor Version
39 | // Build Number
40 | // Revision
41 | // You can specify all the values or you can default the Build and Revision Numbers
42 | // by using the '*' as shown below:
43 | // [assembly: AssemblyVersion("1.0.*")]
44 | [assembly: AssemblyVersion("1.2")]
45 |
46 | // This is also assigned to 'AssemblyInformationalVersion' which is the product version
47 | // Standard Way: [major].[minor].[bugfix].[build]
48 | // .NET Convention: Third digit is the auto-incremented build version. Fourth digit is revision, which is service pack no
49 | [assembly: AssemblyFileVersion("1.2.0.0")]
50 | /*
51 | * AssemblyVersion should only be changed for major changes or breaking changes since any change to the
52 | * AssemblyVersion would force every .NET application referencing the assembly to re-compile against the
53 | * new version!
54 | *
55 | * Do not change the AssemblyVersion for a servicing release which is intended to be backwards compatible.
56 | * Do change the AssemblyVersion for a release that you know has breaking changes.
57 | *
58 | * Remember that it’s the AssemblyFileVersion that contains all the interesting servicing information
59 | * (it’s the Revision part of this version that tells you what Service Pack you’re on)
60 | */
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2011 Teoman Soygul and contributors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/NBug.Configurator/AboutBox.Designer.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug.Configurator/AboutBox.Designer.cs
--------------------------------------------------------------------------------
/NBug.Configurator/CustomPreviewForm.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Configurator
8 | {
9 | using System;
10 | using System.Windows.Forms;
11 |
12 | using NBug.Core.Reporting.Info;
13 | using NBug.Core.UI;
14 |
15 | internal partial class CustomPreviewForm : Form
16 | {
17 | private UIDialogResult uiDialogResult;
18 |
19 | internal CustomPreviewForm()
20 | {
21 | this.InitializeComponent();
22 | }
23 |
24 | internal UIDialogResult ShowDialog(Report report)
25 | {
26 | this.Text = string.Format("{0} CustomUI {1}", report.GeneralInfo.HostApplication, Settings.Resources.UI_Dialog_Normal_Title);
27 | this.exceptionMessageLabel.Text = report.GeneralInfo.ExceptionMessage;
28 |
29 | this.ShowDialog();
30 |
31 | return this.uiDialogResult;
32 | }
33 |
34 | private void ContinueButton_Click(object sender, EventArgs e)
35 | {
36 | this.uiDialogResult = new UIDialogResult(ExecutionFlow.ContinueExecution, SendReport.Send);
37 | this.Close();
38 | }
39 |
40 | private void QuitButton_Click(object sender, EventArgs e)
41 | {
42 | this.uiDialogResult = new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send);
43 | this.Close();
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/NBug.Configurator/PreviewForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace NBug.Configurator
2 | {
3 | partial class PreviewForm
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.closeButton = new System.Windows.Forms.Button();
32 | this.consoleOutputTextBox = new System.Windows.Forms.TextBox();
33 | this.consoleOutputLabel = new System.Windows.Forms.Label();
34 | this.SuspendLayout();
35 | //
36 | // closeButton
37 | //
38 | this.closeButton.Location = new System.Drawing.Point(321, 153);
39 | this.closeButton.Name = "closeButton";
40 | this.closeButton.Size = new System.Drawing.Size(58, 22);
41 | this.closeButton.TabIndex = 0;
42 | this.closeButton.Text = "&Close";
43 | this.closeButton.UseVisualStyleBackColor = true;
44 | this.closeButton.Click += new System.EventHandler(this.CloseButton_Click);
45 | //
46 | // consoleOutputTextBox
47 | //
48 | this.consoleOutputTextBox.BackColor = System.Drawing.Color.Black;
49 | this.consoleOutputTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
50 | this.consoleOutputTextBox.ForeColor = System.Drawing.Color.White;
51 | this.consoleOutputTextBox.Location = new System.Drawing.Point(12, 25);
52 | this.consoleOutputTextBox.Multiline = true;
53 | this.consoleOutputTextBox.Name = "consoleOutputTextBox";
54 | this.consoleOutputTextBox.ReadOnly = true;
55 | this.consoleOutputTextBox.Size = new System.Drawing.Size(367, 122);
56 | this.consoleOutputTextBox.TabIndex = 1;
57 | //
58 | // consoleOutputLabel
59 | //
60 | this.consoleOutputLabel.AutoSize = true;
61 | this.consoleOutputLabel.Location = new System.Drawing.Point(12, 9);
62 | this.consoleOutputLabel.Name = "consoleOutputLabel";
63 | this.consoleOutputLabel.Size = new System.Drawing.Size(83, 13);
64 | this.consoleOutputLabel.TabIndex = 2;
65 | this.consoleOutputLabel.Text = "Console Output:";
66 | //
67 | // PreviewForm
68 | //
69 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
70 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
71 | this.ClientSize = new System.Drawing.Size(391, 181);
72 | this.Controls.Add(this.consoleOutputLabel);
73 | this.Controls.Add(this.consoleOutputTextBox);
74 | this.Controls.Add(this.closeButton);
75 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
76 | this.Name = "PreviewForm";
77 | this.ShowIcon = false;
78 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
79 | this.Text = "Preview";
80 | this.ResumeLayout(false);
81 | this.PerformLayout();
82 |
83 | }
84 |
85 | #endregion
86 |
87 | private System.Windows.Forms.Button closeButton;
88 | private System.Windows.Forms.TextBox consoleOutputTextBox;
89 | private System.Windows.Forms.Label consoleOutputLabel;
90 | }
91 | }
--------------------------------------------------------------------------------
/NBug.Configurator/PreviewForm.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Configurator
8 | {
9 | using System;
10 | using System.IO;
11 | using System.Windows.Forms;
12 |
13 | using NBug.Core.Reporting.Info;
14 | using NBug.Core.UI.Console;
15 | using NBug.Core.UI.Custom;
16 | using NBug.Core.UI.WinForms;
17 | using NBug.Core.UI.WPF;
18 | using NBug.Core.Util.Serialization;
19 | using NBug.Enums;
20 |
21 | internal partial class PreviewForm : Form
22 | {
23 | public PreviewForm()
24 | {
25 | this.InitializeComponent();
26 | }
27 |
28 | internal void ShowDialog(UIMode uiMode, UIProvider uiProvider)
29 | {
30 | var exception =
31 | new SerializableException(new ArgumentException("Argument exception preview.", new Exception("Inner exception for argument exception.")));
32 | var report = new Report(exception);
33 |
34 | var consoleOut = new StringWriter();
35 | Console.SetOut(consoleOut);
36 |
37 | if (uiProvider == UIProvider.Console)
38 | {
39 | ConsoleUI.ShowDialog(uiMode, exception, report);
40 | this.consoleOutputTextBox.Text = consoleOut.ToString();
41 | this.ShowDialog();
42 | }
43 | else if (uiProvider == UIProvider.WinForms)
44 | {
45 | WinFormsUI.ShowDialog(uiMode, exception, report);
46 | this.Close();
47 | }
48 | else if (uiProvider == UIProvider.WPF)
49 | {
50 | WPFUI.ShowDialog(uiMode, exception, report);
51 | this.Close();
52 | }
53 | else if (uiProvider == UIProvider.Custom)
54 | {
55 | CustomUI.ShowDialog(uiMode, exception, report);
56 | this.Close();
57 | }
58 | else
59 | {
60 | throw new ArgumentException("Parameter supplied for UIProvider argument is invalid.");
61 | }
62 | }
63 |
64 | private void CloseButton_Click(object sender, EventArgs e)
65 | {
66 | this.Close();
67 | }
68 | }
69 | }
--------------------------------------------------------------------------------
/NBug.Configurator/Program.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Configurator
8 | {
9 | using System;
10 | using System.Windows.Forms;
11 |
12 | public static class Program
13 | {
14 | ///
15 | /// The main entry point for the application.
16 | ///
17 | [STAThread]
18 | public static void Main()
19 | {
20 | Application.EnableVisualStyles();
21 | Application.SetCompatibleTextRenderingDefault(false);
22 | Application.Run(new MainForm());
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/NBug.Configurator/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 |
8 |
9 | using System.Reflection;
10 | using System.Runtime.InteropServices;
11 |
12 | // General Information about an assembly is controlled through the following
13 | // set of attributes. Change these attribute values to modify the information
14 | // associated with an assembly.
15 | [assembly: AssemblyTitle("NBug.Configurator")]
16 | [assembly: AssemblyDescription("NBug Configurator Application created by Teoman Soygul.")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | // The following GUID is for the ID of the typelib if this project is exposed to COM
25 | [assembly: Guid("ee735b48-b461-4d60-b02d-08434a21c447")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | // Major Version
29 | // Minor Version
30 | // Build Number
31 | // Revision
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
--------------------------------------------------------------------------------
/NBug.Configurator/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.225
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace NBug.Configurator.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NBug.Configurator.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | internal static System.Drawing.Bitmap help {
64 | get {
65 | object obj = ResourceManager.GetObject("help", resourceCulture);
66 | return ((System.Drawing.Bitmap)(obj));
67 | }
68 | }
69 |
70 | internal static System.Drawing.Bitmap Icon_16 {
71 | get {
72 | object obj = ResourceManager.GetObject("Icon_16", resourceCulture);
73 | return ((System.Drawing.Bitmap)(obj));
74 | }
75 | }
76 |
77 | internal static System.Drawing.Bitmap run {
78 | get {
79 | object obj = ResourceManager.GetObject("run", resourceCulture);
80 | return ((System.Drawing.Bitmap)(obj));
81 | }
82 | }
83 |
84 | internal static System.Drawing.Bitmap save {
85 | get {
86 | object obj = ResourceManager.GetObject("save", resourceCulture);
87 | return ((System.Drawing.Bitmap)(obj));
88 | }
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/NBug.Configurator/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.225
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace NBug.Configurator.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/NBug.Configurator/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/NBug.Configurator/SubmitPanels/Custom/Custom.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace NBug.Configurator.SubmitPanels.Custom
2 | {
3 | partial class Custom
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Custom));
32 | this.exampleCode = new System.Windows.Forms.TextBox();
33 | this.SuspendLayout();
34 | //
35 | // exampleCode
36 | //
37 | this.exampleCode.BackColor = System.Drawing.SystemColors.Control;
38 | this.exampleCode.BorderStyle = System.Windows.Forms.BorderStyle.None;
39 | this.exampleCode.ForeColor = System.Drawing.SystemColors.AppWorkspace;
40 | this.exampleCode.Location = new System.Drawing.Point(3, 3);
41 | this.exampleCode.Multiline = true;
42 | this.exampleCode.Name = "exampleCode";
43 | this.exampleCode.ReadOnly = true;
44 | this.exampleCode.Size = new System.Drawing.Size(454, 211);
45 | this.exampleCode.TabIndex = 44;
46 | this.exampleCode.TabStop = false;
47 | this.exampleCode.Text = resources.GetString("exampleCode.Text");
48 | //
49 | // Custom
50 | //
51 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
52 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
53 | this.Controls.Add(this.exampleCode);
54 | this.Name = "Custom";
55 | this.Size = new System.Drawing.Size(475, 231);
56 | this.ResumeLayout(false);
57 | this.PerformLayout();
58 |
59 | }
60 |
61 | #endregion
62 |
63 | private System.Windows.Forms.TextBox exampleCode;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/NBug.Configurator/SubmitPanels/Custom/Custom.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Forms;
2 |
3 | namespace NBug.Configurator.SubmitPanels.Custom
4 | {
5 | public partial class Custom : UserControl, ISubmitPanel
6 | {
7 | public Custom()
8 | {
9 | InitializeComponent();
10 | }
11 |
12 |
13 | public string ConnectionString
14 | {
15 | get
16 | {
17 | var custom = new Core.Submission.Custom.Custom();
18 | return custom.ConnectionString;
19 | }
20 |
21 | set
22 | {
23 | //additional connection string parameters are not supported for Custom submission.
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/NBug.Configurator/SubmitPanels/ISubmitPanel.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Configurator.SubmitPanels
8 | {
9 | internal interface ISubmitPanel
10 | {
11 | string ConnectionString { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/NBug.Configurator/SubmitPanels/Tracker/Redmine.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Configurator.SubmitPanels.Tracker
8 | {
9 | using System;
10 | using System.Windows.Forms;
11 |
12 | public partial class Redmine : UserControl, ISubmitPanel
13 | {
14 | public Redmine()
15 | {
16 | this.InitializeComponent();
17 | }
18 |
19 | public string ConnectionString
20 | {
21 | get
22 | {
23 | // Check the mendatory fields
24 | if (string.IsNullOrEmpty(this.trackerURLTextBox.Text))
25 | {
26 | MessageBox.Show(
27 | "Mandatory field \"" + this.trackerURLLabel.Name + "\" cannot be left blank.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
28 | return null;
29 | }
30 | else if (string.IsNullOrEmpty(this.projectIDTextBox.Text))
31 | {
32 | MessageBox.Show(
33 | "Mandatory field \"" + this.projectIDLabel.Name + "\" cannot be left blank.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
34 | return null;
35 | }
36 |
37 | // Do fixes
38 | if (!this.trackerURLTextBox.Text.EndsWith("/"))
39 | {
40 | this.trackerURLTextBox.Text += "/";
41 | }
42 |
43 | var redmine = new Core.Submission.Tracker.Redmine
44 | {
45 | Url = this.trackerURLTextBox.Text,
46 | ProjectId = this.projectIDTextBox.Text,
47 | TrackerId = this.trackerIDTextBox.Text,
48 | PriorityId = this.priorityIDTextBox.Text,
49 | CategoryId = this.categoryIDTextBox.Text,
50 | CustomSubject = this.customSubjectTextBox.Text,
51 | FixedVersionId = this.fixedVersionIDTextBox.Text,
52 | AssignedToId = this.assignedToIDTextBox.Text,
53 | ParentId = this.parentIDTextBox.Text,
54 | StatusId = this.statusIDTextBox.Text,
55 | AuthorId = this.authorIDTextBox.Text
56 | };
57 |
58 | if (this.apiKeyRadioButton.Checked)
59 | {
60 | redmine.ApiKey = this.apiKeyTextBox.Text;
61 | }
62 |
63 | return redmine.ConnectionString;
64 | }
65 |
66 | set
67 | {
68 | var redmine = new Core.Submission.Tracker.Redmine(value);
69 |
70 | this.trackerURLTextBox.Text = redmine.Url;
71 | this.projectIDTextBox.Text = redmine.ProjectId;
72 | this.trackerIDTextBox.Text = redmine.TrackerId;
73 | this.priorityIDTextBox.Text = redmine.PriorityId;
74 | this.categoryIDTextBox.Text = redmine.CategoryId;
75 | this.customSubjectTextBox.Text = redmine.CustomSubject;
76 | this.fixedVersionIDTextBox.Text = redmine.FixedVersionId;
77 | this.assignedToIDTextBox.Text = redmine.AssignedToId;
78 | this.parentIDTextBox.Text = redmine.ParentId;
79 | this.statusIDTextBox.Text = redmine.StatusId;
80 | this.authorIDTextBox.Text = redmine.AuthorId;
81 |
82 | if (!string.IsNullOrEmpty(redmine.ApiKey))
83 | {
84 | this.apiKeyRadioButton.Checked = true;
85 | this.apiKeyTextBox.Text = redmine.ApiKey;
86 | }
87 | else
88 | {
89 | this.anonymousRadioButton.Checked = true;
90 | }
91 | }
92 | }
93 |
94 | private void AnonymousRadioButton_CheckedChanged(object sender, EventArgs e)
95 | {
96 | if (this.anonymousRadioButton.Checked)
97 | {
98 | this.apiKeyTextBox.Enabled = false;
99 | }
100 | }
101 |
102 | private void ApiKeyRadioButton_CheckedChanged(object sender, EventArgs e)
103 | {
104 | if (this.apiKeyRadioButton.Checked)
105 | {
106 | this.apiKeyTextBox.Enabled = true;
107 | }
108 | }
109 | }
110 | }
--------------------------------------------------------------------------------
/NBug.Configurator/SubmitPanels/Web/Ftp.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Configurator.SubmitPanels.Web
8 | {
9 | using System;
10 | using System.Windows.Forms;
11 |
12 | public partial class Ftp : UserControl, ISubmitPanel
13 | {
14 | public Ftp()
15 | {
16 | this.InitializeComponent();
17 | }
18 |
19 | public string ConnectionString
20 | {
21 | get
22 | {
23 | // Check the mendatory fields
24 | if (string.IsNullOrEmpty(this.urlTextBox.Text))
25 | {
26 | MessageBox.Show(
27 | "Mandatory field \"" + this.urlTextBox.Name + "\" cannot be left blank.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
28 | return null;
29 | }
30 |
31 | // Do fixes
32 | if (!this.urlTextBox.Text.EndsWith("/"))
33 | {
34 | this.urlTextBox.Text += "/";
35 | }
36 |
37 | var ftp = new Core.Submission.Web.Ftp { Url = this.urlTextBox.Text };
38 |
39 | if (this.useSslCheckBox.Checked)
40 | {
41 | ftp.Usessl = "true";
42 | }
43 |
44 | if (this.usernamePasswordRadioButton.Checked)
45 | {
46 | ftp.Username = this.usernameTextBox.Text;
47 | ftp.Password = this.passwordTextBox.Text;
48 | }
49 |
50 | return ftp.ConnectionString;
51 | }
52 |
53 | set
54 | {
55 | var ftp = new Core.Submission.Web.Ftp(value);
56 |
57 | this.urlTextBox.Text = ftp.Url;
58 |
59 | if (!string.IsNullOrEmpty(ftp.Usessl))
60 | {
61 | this.useSslCheckBox.Checked = Convert.ToBoolean(ftp.Usessl);
62 | }
63 |
64 | if (!string.IsNullOrEmpty(ftp.Username))
65 | {
66 | this.usernameTextBox.Text = ftp.Username;
67 | this.passwordTextBox.Text = ftp.Password;
68 | this.usernamePasswordRadioButton.Checked = true;
69 | }
70 | }
71 | }
72 |
73 | private void UsernamePasswordRadioButton_CheckedChanged(object sender, EventArgs e)
74 | {
75 | if (this.usernamePasswordRadioButton.Checked)
76 | {
77 | this.usernameTextBox.Enabled = true;
78 | this.passwordTextBox.Enabled = true;
79 | }
80 | else
81 | {
82 | this.usernameTextBox.Enabled = false;
83 | this.passwordTextBox.Enabled = false;
84 | }
85 | }
86 | }
87 | }
--------------------------------------------------------------------------------
/NBug.Configurator/SubmitPanels/Web/Http.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Configurator.SubmitPanels.Web
8 | {
9 | using System.Windows.Forms;
10 |
11 | public partial class Http : UserControl, ISubmitPanel
12 | {
13 | public Http()
14 | {
15 | this.InitializeComponent();
16 | }
17 |
18 | public string ConnectionString
19 | {
20 | get
21 | {
22 | // Check the mendatory fields
23 | if (string.IsNullOrEmpty(this.urlTextBox.Text))
24 | {
25 | MessageBox.Show(
26 | "Mandatory field \"" + this.urlTextBox.Name + "\" cannot be left blank.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
27 | return null;
28 | }
29 |
30 | // Do fixes
31 | if (!this.urlTextBox.Text.EndsWith("/"))
32 | {
33 | this.urlTextBox.Text += "/";
34 | }
35 |
36 | var http = new Core.Submission.Web.Http { Url = this.urlTextBox.Text };
37 |
38 | return http.ConnectionString;
39 | }
40 |
41 | set
42 | {
43 | var http = new Core.Submission.Web.Http(value);
44 | this.urlTextBox.Text = http.Url;
45 | }
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/NBug.Configurator/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/NBug.Configurator/resources/AboutBox.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug.Configurator/resources/AboutBox.png
--------------------------------------------------------------------------------
/NBug.Configurator/resources/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug.Configurator/resources/Icon.png
--------------------------------------------------------------------------------
/NBug.Configurator/resources/Icon_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug.Configurator/resources/Icon_16.png
--------------------------------------------------------------------------------
/NBug.Configurator/resources/help.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug.Configurator/resources/help.png
--------------------------------------------------------------------------------
/NBug.Configurator/resources/run.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug.Configurator/resources/run.png
--------------------------------------------------------------------------------
/NBug.Configurator/resources/save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug.Configurator/resources/save.png
--------------------------------------------------------------------------------
/NBug.Tests/Functional/DeveloperUITests.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Tests.Functional
8 | {
9 | using System;
10 |
11 | using NBug.Core.Reporting;
12 | using NBug.Core.Submission;
13 | using NBug.Core.UI;
14 | using NBug.Core.Util;
15 | using NBug.Core.Util.Exceptions;
16 | using NBug.Enums;
17 | using NBug.Tests.Tools.Extensions;
18 | using NBug.Tests.Tools.Fixtures;
19 | using NBug.Tests.Tools.Stubs;
20 |
21 | using Xunit;
22 |
23 | public class DeveloperUITests : IUseFixture, IUseFixture
24 | {
25 | [Fact]
26 | public void ConfigErrorWithInternalConfigurationExceptionViewer()
27 | {
28 | Settings.AddDestinationFromConnectionString(
29 | "Type=Mail;From=postmaster@localhost;FromName=NBug Internal Error Reporter;To=postmaster@localhost;SmtpServer=localhost;");
30 | new BugReport().Report(new DummyArgumentException(), ExceptionThread.Main);
31 | new Dispatcher(false);
32 |
33 | Settings.UIMode = UIMode.Minimal;
34 | Settings.UIProvider = UIProvider.Auto; // This is invalid!
35 | Assert.Equal(new BugReport().Report(new Exception(), ExceptionThread.Main), ExecutionFlow.ContinueExecution);
36 | }
37 |
38 | [Fact]
39 | [UI]
40 | public void InternalConfigurationExceptionViewer()
41 | {
42 | NBugConfigurationException.Create(() => Settings.UIMode, "Testing invalid UIMode configuration exception.");
43 | }
44 |
45 | [Fact]
46 | [UI]
47 | public void InternalLogViewerWithTrace()
48 | {
49 | // ToDo: Run it in sync (blocking) mode for testing or otherwise the test runner process will be corrupted
50 | // InternalLogViewer.LogEntry("Test log entry", LoggerCategory.NBugTrace);
51 | }
52 |
53 | [Fact]
54 | [UI]
55 | public void InternalRuntimeExceptionViewer()
56 | {
57 | new NBugRuntimeException("Testing runtime exception.", new DummyArgumentException());
58 | }
59 |
60 | [Fact]
61 | [UI]
62 | public void InternalRuntimeExceptionViewerWithoutInnerException()
63 | {
64 | new NBugRuntimeException("Testing runtime exception without inner exception.");
65 | }
66 |
67 | public void SetFixture(UIFixture data)
68 | {
69 | }
70 |
71 | public void SetFixture(SettingsFixture data)
72 | {
73 | }
74 | }
75 | }
--------------------------------------------------------------------------------
/NBug.Tests/Functional/WinFormsUITests.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Tests.Functional
8 | {
9 | using NBug.Core.Reporting.Info;
10 | using NBug.Core.UI.WinForms;
11 | using NBug.Enums;
12 | using NBug.Tests.Tools.Extensions;
13 | using NBug.Tests.Tools.Fixtures;
14 | using NBug.Tests.Tools.Stubs;
15 |
16 | using Xunit;
17 |
18 | public class WinFormsUITests : IUseFixture, IUseFixture
19 | {
20 | [Fact]
21 | [UI]
22 | public void Full()
23 | {
24 | var exception = new DummySerializableException();
25 | WinFormsUI.ShowDialog(UIMode.Full, exception, new Report(exception));
26 | }
27 |
28 | [Fact]
29 | [UI]
30 | public void Minimal()
31 | {
32 | var exception = new DummySerializableException();
33 | WinFormsUI.ShowDialog(UIMode.Minimal, exception, new Report(exception));
34 | }
35 |
36 | public void SetFixture(SettingsFixture settings)
37 | {
38 | }
39 |
40 | public void SetFixture(UIFixture data)
41 | {
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/NBug.Tests/Integration/BugReportTests.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Tests.Integration
8 | {
9 | using NBug.Core.Reporting;
10 | using NBug.Core.UI;
11 | using NBug.Core.Util;
12 | using NBug.Tests.Tools.Fixtures;
13 | using NBug.Tests.Tools.Stubs;
14 |
15 | using Xunit;
16 |
17 | public class BugReportTests : IUseFixture, IUseFixture
18 | {
19 | private ReportFixture report;
20 |
21 | [Fact]
22 | public void GenerateBugReport()
23 | {
24 | Assert.Equal(new BugReport().Report(new DummyArgumentException(), ExceptionThread.UI_WinForms), ExecutionFlow.BreakExecution);
25 |
26 | this.report.VerifyAndDeleteCompressedReportFile();
27 | }
28 |
29 | public void SetFixture(SettingsFixture settings)
30 | {
31 | settings.InitializeStandardSettings();
32 | }
33 |
34 | public void SetFixture(ReportFixture reportFixture)
35 | {
36 | this.report = reportFixture;
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/NBug.Tests/Integration/HandlerTests.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Tests.Integration
8 | {
9 | using System;
10 | using System.Threading;
11 | using System.Threading.Tasks;
12 |
13 | using NBug.Tests.Tools.Fixtures;
14 |
15 | using Xunit;
16 |
17 | public class HandlerTests : IUseFixture, IUseFixture
18 | {
19 | private ReportFixture report;
20 |
21 | [Fact]
22 | public void CorruptThreadExceptionHandler()
23 | {
24 | Settings.HandleProcessCorruptedStateExceptions = true;
25 | Handler.ThreadException(this, new ThreadExceptionEventArgs(new Exception("Testing a corrupt WinForms UI thread Exception.")));
26 | this.report.VerifyAndDeleteCompressedReportFile();
27 | }
28 |
29 | [Fact]
30 | public void CorruptUnhandledExceptionHandler()
31 | {
32 | Settings.HandleProcessCorruptedStateExceptions = true;
33 |
34 | // Since there are no UI related assemblies loaded, this should behave as a console app exception
35 | Handler.UnhandledException(
36 | this, new UnhandledExceptionEventArgs(new AccessViolationException("Testing a corrupt ConsoleApp main thread AccessViolationException."), true));
37 | this.report.VerifyAndDeleteCompressedReportFile();
38 | }
39 |
40 | [Fact]
41 | public void CorruptUnobservedTaskExceptionHandler()
42 | {
43 | Settings.HandleProcessCorruptedStateExceptions = true;
44 | Handler.UnobservedTaskException(
45 | this,
46 | new UnobservedTaskExceptionEventArgs(
47 | new AggregateException("Testing a corrupt Task exception.", new Exception("Task exception inner exception as aggregated exception."))));
48 | this.report.VerifyAndDeleteCompressedReportFile();
49 | }
50 |
51 | public void SetFixture(SettingsFixture settings)
52 | {
53 | settings.InitializeStandardSettings();
54 |
55 | // This is requred otherwise the test runner will be forced to quit before test finishes
56 | Settings.ExitApplicationImmediately = false;
57 | }
58 |
59 | public void SetFixture(ReportFixture reportFixture)
60 | {
61 | this.report = reportFixture;
62 | }
63 |
64 | [Fact]
65 | public void ThreadExceptionHandler()
66 | {
67 | Handler.ThreadException(this, new ThreadExceptionEventArgs(new Exception("Testing a WinForms UI thread Exception.")));
68 | this.report.VerifyAndDeleteCompressedReportFile();
69 | }
70 |
71 | [Fact] // Simulate System.AppDomain.UnhandledException event on the main thread in the default appdomain
72 | public void UnhandledExceptionHandler()
73 | {
74 | // Since there are no UI related assemblies loaded, this should behave as a console app exception
75 | Handler.UnhandledException(this, new UnhandledExceptionEventArgs(new Exception("Testing a ConsoleApp main thread Exception."), true));
76 | this.report.VerifyAndDeleteCompressedReportFile();
77 | }
78 |
79 | [Fact]
80 | public void UnobservedTaskExceptionHandler()
81 | {
82 | Handler.UnobservedTaskException(
83 | this,
84 | new UnobservedTaskExceptionEventArgs(
85 | new AggregateException("Testing a Task exception.", new Exception("Task exception inner exception as aggregated exception."))));
86 | this.report.VerifyAndDeleteCompressedReportFile();
87 | }
88 | }
89 | }
--------------------------------------------------------------------------------
/NBug.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 |
8 |
9 | using System.Reflection;
10 | using System.Runtime.InteropServices;
11 |
12 | // General Information about an assembly is controlled through the following
13 | // set of attributes. Change these attribute values to modify the information
14 | // associated with an assembly.
15 | [assembly: AssemblyTitle("NBug.Tests")]
16 | [assembly: AssemblyDescription("NBug Unit Testing Library created by Teoman Soygul.")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | // The following GUID is for the ID of the typelib if this project is exposed to COM
25 | [assembly: Guid("2063af3c-6402-4000-b41e-b0e14cc10ec0")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | // Major Version
29 | // Minor Version
30 | // Build Number
31 | // Revision
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
--------------------------------------------------------------------------------
/NBug.Tests/Tools/Extensions/UIAttribute.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Tests.Tools.Extensions
8 | {
9 | using Xunit;
10 |
11 | public class UIAttribute : TraitAttribute
12 | {
13 | public UIAttribute()
14 | : base("Category", "UI")
15 | {
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/NBug.Tests/Tools/Fixtures/SettingsFixture.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Tests.Tools.Fixtures
8 | {
9 | using System;
10 | using System.Collections.Generic;
11 | using System.IO;
12 | using System.Linq;
13 | using System.Reflection;
14 | using System.Xml.Serialization;
15 |
16 | using NBug.Core.Util;
17 | using NBug.Enums;
18 | using NBug.Properties;
19 |
20 | using Settings = NBug.Settings;
21 |
22 | public class SettingsFixture : IDisposable
23 | {
24 | // This is static for performance reasons (also not disposed at the destructor due to the same reason)
25 | private static Stream settings;
26 |
27 | private List dispatcherDestinations;
28 |
29 | public SettingsFixture()
30 | {
31 | if (settings == null)
32 | {
33 | // Assembly.GetEntryAssembly() is null for tests wihtout GUI runner so filling it in to prevent null object exceptions
34 | Settings.EntryAssembly = Assembly.GetExecutingAssembly();
35 |
36 | settings = new MemoryStream();
37 | Settings.SaveCustomSettings(settings, false);
38 | }
39 | }
40 |
41 | public void Dispose()
42 | {
43 | this.ReloadDefaults();
44 | }
45 |
46 | internal void InitializeStandardSettings()
47 | {
48 | Settings.SkipDispatching = true;
49 | Settings.UIMode = UIMode.None;
50 | Settings.WriteLogToDisk = false;
51 | }
52 |
53 | ///
54 | /// Returns null if the custom settings file is not found so check for null object reference.
55 | ///
56 | ///
57 | /// The .
58 | ///
59 | internal List ReadCustomDispatcherDestinationSettings(string protocol)
60 | {
61 | // This generates a sample settings file for future reference
62 | /*this.dispatcherDestinations.Add("Just testing this stuff.");
63 | var serializer = new XmlSerializer(typeof(List));
64 | using (FileStream stream = new FileStream("DispatcherDestinations.xml", FileMode.Create))
65 | {
66 | serializer.Serialize(stream, this.dispatcherDestinations);
67 | }*/
68 |
69 | // Make sure that settings are red and cached only once during the object lifetime
70 | if (this.dispatcherDestinations == null)
71 | {
72 | this.dispatcherDestinations = new List();
73 | var path = Path.Combine(Settings.NBugDirectory, "DispatcherDestinations.xml");
74 |
75 | if (!File.Exists(path))
76 | {
77 | path = Path.Combine(
78 | Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Docs\\ASFT\\Dev\\_Tools\\Settings\\DispatcherDestinations.xml");
79 |
80 | if (!File.Exists(path))
81 | {
82 | return null;
83 | }
84 | }
85 |
86 | var serializer = new XmlSerializer(typeof(List));
87 | using (var stream = new FileStream(path, FileMode.Open))
88 | {
89 | this.dispatcherDestinations = (List)serializer.Deserialize(stream);
90 | }
91 | }
92 |
93 | return
94 | (from destination in this.dispatcherDestinations where ConnectionStringParser.Parse(destination)["Type"].Equals(protocol) select destination)
95 | .ToList();
96 | }
97 |
98 | internal void ReloadDefaults()
99 | {
100 | SettingsOverride.LoadCustomSettings(settings);
101 | }
102 | }
103 | }
--------------------------------------------------------------------------------
/NBug.Tests/Tools/Fixtures/UIFixture.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Tests.Tools.Fixtures
8 | {
9 | using System.Windows.Forms;
10 |
11 | public class UIFixture
12 | {
13 | public UIFixture()
14 | {
15 | Application.EnableVisualStyles();
16 | Application.SetCompatibleTextRenderingDefault(false);
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/NBug.Tests/Tools/Stubs/DummyArgumentException.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Tests.Tools.Stubs
8 | {
9 | using System;
10 | using System.Collections;
11 | using System.Collections.Generic;
12 |
13 | public class DummyArgumentException : ArgumentException
14 | {
15 | public DummyArgumentException()
16 | : base("Testing MyArgumentException.", "MyDummyParameter", new Exception("Testing inner exception for MyArgumentException."))
17 | {
18 | }
19 |
20 | public override IDictionary Data
21 | {
22 | get
23 | {
24 | return new Dictionary { { "StringDataProperty", "Just testing the data property with a set of strings as a dictionary." } };
25 | }
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/NBug.Tests/Tools/Stubs/DummySerializableException.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Tests.Tools.Stubs
8 | {
9 | using NBug.Core.Util.Serialization;
10 |
11 | public class DummySerializableException : SerializableException
12 | {
13 | public DummySerializableException()
14 | : base(new DummyArgumentException())
15 | {
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/NBug.Tests/Unit/BugReportTests.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Tests.Unit
8 | {
9 | public class BugReportTests
10 | {
11 | // "Setup", "Returns", "Verify", and "Assert.xxx"
12 |
13 | /*[Fact]
14 | public void Test()
15 | {
16 | var report = new Mock();
17 | report.SetupProperty(x => x.General.UserDescription, "test");
18 | Assert.True(report.Object.General.UserDescription == "test");
19 | }*/
20 | }
21 | }
--------------------------------------------------------------------------------
/NBug.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/NBug/Core/Reporting/Feedback.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Reporting
8 | {
9 | using System;
10 |
11 | using NBug.Core.Reporting.Info;
12 | using NBug.Core.Util.Logging;
13 |
14 | internal class Feedback
15 | {
16 | private Report report;
17 |
18 | internal Feedback()
19 | {
20 | try
21 | {
22 | // ToDo: Wrap and submit the feedback using Submit.Dispatcher()
23 | this.report = new Report(null);
24 | }
25 | catch (Exception exception)
26 | {
27 | Logger.Error("An exception occurred while sending a user feedback. See the inner exception for details.", exception);
28 | }
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/NBug/Core/Reporting/Info/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Reporting.Info
8 | {
9 | public class AssemblyInfo
10 | {
11 | }
12 | }
--------------------------------------------------------------------------------
/NBug/Core/Reporting/Info/ConfigurationInfo.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Reporting.Info
8 | {
9 | public class ConfigurationInfo
10 | {
11 | }
12 | }
--------------------------------------------------------------------------------
/NBug/Core/Reporting/Info/GeneralInfo.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Reporting.Info
8 | {
9 | using System;
10 | using System.Diagnostics;
11 | using System.Reflection;
12 |
13 | using NBug.Core.Util.Serialization;
14 |
15 | [Serializable]
16 | public class GeneralInfo
17 | {
18 | ///
19 | /// Initializes a new instance of the class. This is the default constructor provided for XML
20 | /// serialization and de-serialization.
21 | ///
22 | public GeneralInfo()
23 | {
24 | }
25 |
26 | internal GeneralInfo(SerializableException serializableException)
27 | {
28 | // this.HostApplication = Settings.EntryAssembly.GetName().Name; // Does not get the extensions of the file!
29 | this.HostApplication = Settings.EntryAssembly.GetLoadedModules()[0].Name;
30 |
31 | // this.HostApplicationVersion = Settings.EntryAssembly.GetName().Version.ToString(); // Gets AssemblyVersion not AssemblyFileVersion
32 | this.HostApplicationVersion = this.NBugVersion = FileVersionInfo.GetVersionInfo(Settings.EntryAssembly.Location).ProductVersion;
33 |
34 | // this.NBugVersion = System.Reflection.Assembly.GetCallingAssembly().GetName().Version.ToString(); // Gets AssemblyVersion not AssemblyFileVersion
35 | this.NBugVersion = FileVersionInfo.GetVersionInfo(Assembly.GetCallingAssembly().Location).ProductVersion;
36 |
37 | this.CLRVersion = Environment.Version.ToString();
38 |
39 | this.DateTime = System.DateTime.UtcNow.ToString();
40 |
41 | if (serializableException != null)
42 | {
43 | this.ExceptionType = serializableException.Type;
44 |
45 | if (!string.IsNullOrEmpty(serializableException.TargetSite))
46 | {
47 | this.TargetSite = serializableException.TargetSite;
48 | }
49 | else if (serializableException.InnerException != null && !string.IsNullOrEmpty(serializableException.InnerException.TargetSite))
50 | {
51 | this.TargetSite = serializableException.InnerException.TargetSite;
52 | }
53 |
54 | this.ExceptionMessage = serializableException.Message;
55 | }
56 | }
57 |
58 | public string CLRVersion { get; set; }
59 |
60 | public string DateTime { get; set; }
61 |
62 | public string ExceptionMessage { get; set; }
63 |
64 | public string ExceptionType { get; set; }
65 |
66 | public string HostApplication { get; set; }
67 |
68 | ///
69 | /// Gets or sets AssemblyFileVersion of host assembly.
70 | ///
71 | public string HostApplicationVersion { get; set; }
72 |
73 | ///
74 | /// Gets or sets AssemblyFileVersion of NBug.dll assembly.
75 | ///
76 | public string NBugVersion { get; set; }
77 |
78 | public string TargetSite { get; set; }
79 |
80 | public string UserDescription { get; set; }
81 | }
82 | }
--------------------------------------------------------------------------------
/NBug/Core/Reporting/Info/Report.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Reporting.Info
8 | {
9 | using System;
10 | using System.IO;
11 | using System.Xml.Linq;
12 | using System.Xml.Serialization;
13 |
14 | using NBug.Core.Util.Serialization;
15 |
16 | [Serializable]
17 | public class Report
18 | {
19 | ///
20 | /// Initializes a new instance of the class to be filled with information later on.
21 | ///
22 | public Report()
23 | {
24 | }
25 |
26 | internal Report(SerializableException serializableException)
27 | {
28 | this.GeneralInfo = new GeneralInfo(serializableException);
29 | }
30 |
31 | ///
32 | /// Gets or sets a custom object property to store user supplied information in the bug report. You need to handle
33 | /// event to fill this property with required information.
34 | ///
35 | public object CustomInfo { get; set; }
36 |
37 | ///
38 | /// Gets or sets the general information about the exception and the system to be presented in the bug report.
39 | ///
40 | public GeneralInfo GeneralInfo { get; set; }
41 |
42 | /*///
43 | /// Gets or sets a custom object property to store user supplied information in the bug report. You need to handle
44 | /// event to fill this property with required information.
45 | ///
46 | public object StaticInfo { get; set; }*/
47 | public override string ToString()
48 | {
49 | var serializer = this.CustomInfo != null
50 | ? new XmlSerializer(typeof(Report), new[] { this.CustomInfo.GetType() })
51 | : new XmlSerializer(typeof(Report));
52 | using (var stream = new MemoryStream())
53 | {
54 | stream.SetLength(0);
55 | serializer.Serialize(stream, this);
56 | stream.Position = 0;
57 | var doc = XDocument.Load(stream);
58 | return doc.Root.ToString();
59 | }
60 | }
61 | }
62 | }
--------------------------------------------------------------------------------
/NBug/Core/Reporting/Info/SystemInfo.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Reporting.Info
8 | {
9 | public class SystemInfo
10 | {
11 | }
12 | }
--------------------------------------------------------------------------------
/NBug/Core/Reporting/MiniDump/DumpTypeFlag.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Reporting.MiniDump
8 | {
9 | using System;
10 |
11 | [Flags]
12 | internal enum DumpTypeFlag : uint
13 | {
14 | // From dbghelp.h:
15 | Normal = 0x00000000,
16 |
17 | WithDataSegs = 0x00000001,
18 |
19 | WithFullMemory = 0x00000002,
20 |
21 | WithHandleData = 0x00000004,
22 |
23 | FilterMemory = 0x00000008,
24 |
25 | ScanMemory = 0x00000010,
26 |
27 | WithUnloadedModules = 0x00000020,
28 |
29 | WithIndirectlyReferencedMemory = 0x00000040,
30 |
31 | FilterModulePaths = 0x00000080,
32 |
33 | WithProcessThreadData = 0x00000100,
34 |
35 | WithPrivateReadWriteMemory = 0x00000200,
36 |
37 | WithoutOptionalData = 0x00000400,
38 |
39 | WithFullMemoryInfo = 0x00000800,
40 |
41 | WithThreadInfo = 0x00001000,
42 |
43 | WithCodeSegs = 0x00002000,
44 |
45 | WithoutAuxiliaryState = 0x00004000,
46 |
47 | WithFullAuxiliaryState = 0x00008000,
48 |
49 | WithPrivateWriteCopyMemory = 0x00010000,
50 |
51 | IgnoreInaccessibleMemory = 0x00020000,
52 |
53 | ValidTypeFlags = 0x0003ffff,
54 | }
55 | }
--------------------------------------------------------------------------------
/NBug/Core/Submission/Custom/Custom.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Submission.Custom
8 | {
9 | using System.IO;
10 |
11 | using NBug.Core.Reporting.Info;
12 | using NBug.Core.Util.Serialization;
13 | using NBug.Events;
14 |
15 | public class CustomFactory : IProtocolFactory
16 | {
17 | public string SupportedType
18 | {
19 | get
20 | {
21 | return "Custom";
22 | }
23 | }
24 |
25 | public IProtocol FromConnectionString(string connectionString)
26 | {
27 | return new Custom(connectionString);
28 | }
29 | }
30 |
31 | public class Custom : ProtocolBase
32 | {
33 | public Custom(string connectionString)
34 | : base(connectionString)
35 | {
36 | }
37 |
38 | public Custom()
39 | {
40 | }
41 |
42 | public override bool Send(string fileName, Stream file, Report report, SerializableException exception)
43 | {
44 | if (Settings.CustomSubmissionHandle == null)
45 | return false;
46 |
47 | var e = new CustomSubmissionEventArgs(fileName, file, report, exception);
48 | Settings.CustomSubmissionHandle.DynamicInvoke(this, e);
49 | return e.Result;
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/NBug/Core/Submission/Database/Ado.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Submission.Database
8 | {
9 | internal class Ado
10 | {
11 | }
12 | }
--------------------------------------------------------------------------------
/NBug/Core/Submission/Database/MsSql.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Submission.Database
8 | {
9 | internal class MsSql
10 | {
11 | }
12 | }
--------------------------------------------------------------------------------
/NBug/Core/Submission/Database/MySql.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Submission.Database
8 | {
9 | internal class MySql
10 | {
11 | }
12 | }
--------------------------------------------------------------------------------
/NBug/Core/Submission/IProtocol.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Submission
8 | {
9 | using System.IO;
10 |
11 | using NBug.Core.Reporting.Info;
12 | using NBug.Core.Util.Serialization;
13 |
14 | ///
15 | /// Implement this to support sending data to a specific location.
16 | ///
17 | /// We recommend you base your implementation on ProtocolBase.
18 | ///
19 | public interface IProtocol
20 | {
21 | ///
22 | /// Connection string suitable for serialization.
23 | ///
24 | string ConnectionString { get; }
25 |
26 | ///
27 | /// Send the report file to the destination.
28 | ///
29 | /// Name of the file (e.g. "Exception_12345.zip")
30 | /// File stream
31 | /// Report
32 | ///
33 | /// True if report was sent successfully.
34 | bool Send(string fileName, Stream file, Report report, SerializableException exception);
35 | }
36 | }
--------------------------------------------------------------------------------
/NBug/Core/Submission/IProtocolFactory.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Submission
8 | {
9 | ///
10 | /// The protocol factory creates an IProtocol instance.
11 | ///
12 | /// This interface is to get around the fact that the IProtocol interface
13 | /// cannot be guaranteed to contain a constructor that takes a connection
14 | /// string. At the same time, we allow the protocol implementation to supply
15 | /// the name of its connection string Type parameter.
16 | ///
17 | /// The protocol factory is only used for protocols that originate as connection
18 | /// strings in a configuration file.
19 | ///
20 | /// Note! Your implementation of this class MUST HAVE a parameterless constructor.
21 | ///
22 | public interface IProtocolFactory
23 | {
24 | string SupportedType { get; }
25 |
26 | IProtocol FromConnectionString(string connectionString);
27 | }
28 | }
--------------------------------------------------------------------------------
/NBug/Core/Submission/ProtocolBase.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Submission
8 | {
9 | using System;
10 | using System.IO;
11 | using System.Linq;
12 | using System.Reflection;
13 |
14 | using NBug.Core.Reporting.Info;
15 | using NBug.Core.Util;
16 | using NBug.Core.Util.Serialization;
17 |
18 | public abstract class ProtocolBase : IProtocol
19 | {
20 | ///
21 | /// Initializes a new instance of the ProtocolBase class to be extended by derived types.
22 | ///
23 | /// Connection string to be parsed.
24 | protected ProtocolBase(string connectionString)
25 | {
26 | var fields = ConnectionStringParser.Parse(connectionString);
27 | var properties = this.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
28 |
29 | foreach (var property in properties.Where(property => property.Name != "Type" && fields.ContainsKey(property.Name)))
30 | {
31 | if (property.PropertyType == typeof(bool))
32 | {
33 | property.SetValue(this, Convert.ToBoolean(fields[property.Name].Trim()), null);
34 | }
35 | else if (property.PropertyType == typeof(int))
36 | {
37 | property.SetValue(this, Convert.ToInt32(fields[property.Name].Trim()), null);
38 | }
39 | else if (property.PropertyType.BaseType == typeof(Enum))
40 | {
41 | property.SetValue(this, Enum.Parse(property.PropertyType, fields[property.Name]), null);
42 | }
43 | else
44 | {
45 | property.SetValue(this, fields[property.Name], null);
46 | }
47 | }
48 | }
49 |
50 | protected ProtocolBase()
51 | {
52 | }
53 |
54 | ///
55 | /// Gets serialized representation of the connection string.
56 | ///
57 | public string ConnectionString
58 | {
59 | get
60 | {
61 | var connectionString = string.Format("Type={0};", this.GetType().Name);
62 | var properties =
63 | this.GetType()
64 | .GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetProperty | BindingFlags.GetProperty)
65 | .Where(p => p.Name != "ConnectionString");
66 |
67 | foreach (var property in properties)
68 | {
69 | var prop = property.GetValue(this, null);
70 | if (prop != null)
71 | {
72 | var val = prop.ToString();
73 |
74 | if (!string.IsNullOrEmpty(val))
75 | {
76 | // Escape = and ; characters
77 | connectionString += string.Format(
78 | "{0}={1};", property.Name.Replace(";", @"\;").Replace("=", @"\="), val.Replace(";", @"\;").Replace("=", @"\="));
79 | }
80 | }
81 | }
82 |
83 | return connectionString;
84 | }
85 | }
86 |
87 | // Password field may contain the illegal ';' character so it is always the last field and isolated
88 | public abstract bool Send(string fileName, Stream file, Report report, SerializableException exception);
89 |
90 | internal string GetSettingsPasswordField(string connectionString)
91 | {
92 | return connectionString.Substring(connectionString.ToLower().IndexOf("password=") + 9)
93 | .Substring(0, connectionString.Substring(connectionString.ToLower().IndexOf("password=") + 9).Length - 1);
94 | }
95 | }
96 | }
--------------------------------------------------------------------------------
/NBug/Core/Submission/Protocols.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2010 - 2011 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Submission
8 | {
9 | // Actually enum names should be singular words!
10 | public enum Protocols
11 | {
12 | Mail,
13 | Redmine,
14 | BugNET,
15 | FTP,
16 | HTTP,
17 | AzureBlobStorage
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/NBug/Core/Submission/Tracker/BugNet.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Submission.Tracker
8 | {
9 | using System.IO;
10 | using System.Net;
11 |
12 | using NBug.Core.Reporting.Info;
13 | using NBug.Core.Util.Serialization;
14 |
15 | internal class BugNet : ProtocolBase
16 | {
17 | internal BugNet(string connectionString)
18 | : base(connectionString)
19 | {
20 | }
21 |
22 | internal BugNet()
23 | {
24 | }
25 |
26 | public override bool Send(string fileName, Stream file, Report report, SerializableException exception)
27 | {
28 | //HttpWebRequest request; //suppress unused Warning
29 |
30 | return true;
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/NBug/Core/Submission/Tracker/Bugzilla.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Submission.Tracker
8 | {
9 | internal class Bugzilla
10 | {
11 | }
12 | }
--------------------------------------------------------------------------------
/NBug/Core/Submission/Tracker/GitHub.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Submission.Tracker
8 | {
9 | internal class GitHub
10 | {
11 | }
12 | }
--------------------------------------------------------------------------------
/NBug/Core/Submission/Tracker/GoogleCode.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Submission.Tracker
8 | {
9 | internal class GoogleCode
10 | {
11 | }
12 | }
--------------------------------------------------------------------------------
/NBug/Core/Submission/Tracker/Mantis/AccountData.cs:
--------------------------------------------------------------------------------
1 | namespace NBug.Core.Submission.Tracker.Mantis
2 | {
3 |
4 | [System.SerializableAttribute(), System.Diagnostics.DebuggerStepThroughAttribute(), System.Xml.Serialization.SoapTypeAttribute(Namespace = "http://futureware.biz/mantisconnect")]
5 | public class AccountData
6 | {
7 |
8 | private string idField;
9 | private string nameField;
10 | private string real_nameField;
11 |
12 | private string emailField;
13 | [System.Xml.Serialization.SoapElementAttribute(DataType = "integer")]
14 | public string id {
15 | get { return this.idField; }
16 | set { this.idField = value; }
17 | }
18 |
19 | public string name {
20 | get { return this.nameField; }
21 | set { this.nameField = value; }
22 | }
23 |
24 | public string real_name {
25 | get { return this.real_nameField; }
26 | set { this.real_nameField = value; }
27 | }
28 |
29 | public string email {
30 | get { return this.emailField; }
31 | set { this.emailField = value; }
32 | }
33 |
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/NBug/Core/Submission/Tracker/Mantis/AttachmentData.cs:
--------------------------------------------------------------------------------
1 | namespace NBug.Core.Submission.Tracker.Mantis
2 | {
3 |
4 | [System.SerializableAttribute(), System.Xml.Serialization.SoapTypeAttribute(Namespace = "http://futureware.biz/mantisconnect")]
5 | public class AttachmentData
6 | {
7 |
8 |
9 | private string idField;
10 |
11 | private string filenameField;
12 |
13 | private string sizeField;
14 |
15 | private string content_typeField;
16 |
17 | private System.DateTime date_submittedField;
18 |
19 | private bool date_submittedFieldSpecified;
20 |
21 | private string download_urlField;
22 |
23 | private string user_idField;
24 | [System.Xml.Serialization.SoapElementAttribute(DataType = "integer")]
25 | public string id {
26 | get { return this.idField; }
27 | set { this.idField = value; }
28 | }
29 |
30 | public string filename {
31 | get { return this.filenameField; }
32 | set { this.filenameField = value; }
33 | }
34 |
35 | [System.Xml.Serialization.SoapElementAttribute(DataType = "integer")]
36 | public string size {
37 | get { return this.sizeField; }
38 | set { this.sizeField = value; }
39 | }
40 |
41 | public string content_type {
42 | get { return this.content_typeField; }
43 | set { this.content_typeField = value; }
44 | }
45 |
46 | public System.DateTime date_submitted {
47 | get { return this.date_submittedField; }
48 | set { this.date_submittedField = value; }
49 | }
50 |
51 | [System.Xml.Serialization.SoapIgnoreAttribute()]
52 | public bool date_submittedSpecified {
53 | get { return this.date_submittedFieldSpecified; }
54 | set { this.date_submittedFieldSpecified = value; }
55 | }
56 |
57 | [System.Xml.Serialization.SoapElementAttribute(DataType = "anyURI")]
58 | public string download_url {
59 | get { return this.download_urlField; }
60 | set { this.download_urlField = value; }
61 | }
62 |
63 | [System.Xml.Serialization.SoapElementAttribute(DataType = "integer")]
64 | public string user_id {
65 | get { return this.user_idField; }
66 | set { this.user_idField = value; }
67 | }
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/NBug/Core/Submission/Tracker/Mantis/CustomFieldValueForIssueData.cs:
--------------------------------------------------------------------------------
1 | namespace NBug.Core.Submission.Tracker.Mantis
2 | {
3 |
4 | [System.SerializableAttribute(), System.Xml.Serialization.SoapTypeAttribute(Namespace = "http://futureware.biz/mantisconnect")]
5 | public class CustomFieldValueForIssueData
6 | {
7 |
8 | private ObjectRef fieldField;
9 |
10 | private string valueField;
11 | public ObjectRef field {
12 | get { return this.fieldField; }
13 | set { this.fieldField = value; }
14 | }
15 |
16 | public string value {
17 | get { return this.valueField; }
18 | set { this.valueField = value; }
19 | }
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/NBug/Core/Submission/Tracker/Mantis/IssueNoteData.cs:
--------------------------------------------------------------------------------
1 | namespace NBug.Core.Submission.Tracker.Mantis
2 | {
3 |
4 | [System.SerializableAttribute(), System.Xml.Serialization.SoapTypeAttribute(Namespace = "http://futureware.biz/mantisconnect")]
5 | public class IssueNoteData
6 | {
7 |
8 |
9 | private string idField;
10 |
11 | private AccountData reporterField;
12 |
13 | private string textField;
14 |
15 | private ObjectRef view_stateField;
16 |
17 | private System.DateTime date_submittedField;
18 |
19 | private bool date_submittedFieldSpecified;
20 |
21 | private System.DateTime last_modifiedField;
22 |
23 | private bool last_modifiedFieldSpecified;
24 |
25 | private string time_trackingField;
26 |
27 | private string note_typeField;
28 |
29 | private string note_attrField;
30 | [System.Xml.Serialization.SoapElementAttribute(DataType = "integer")]
31 | public string id {
32 | get { return this.idField; }
33 | set { this.idField = value; }
34 | }
35 |
36 | public AccountData reporter {
37 | get { return this.reporterField; }
38 | set { this.reporterField = value; }
39 | }
40 |
41 | public string text {
42 | get { return this.textField; }
43 | set { this.textField = value; }
44 | }
45 |
46 | public ObjectRef view_state {
47 | get { return this.view_stateField; }
48 | set { this.view_stateField = value; }
49 | }
50 |
51 | public System.DateTime date_submitted {
52 | get { return this.date_submittedField; }
53 | set { this.date_submittedField = value; }
54 | }
55 |
56 | [System.Xml.Serialization.SoapIgnoreAttribute()]
57 | public bool date_submittedSpecified {
58 | get { return this.date_submittedFieldSpecified; }
59 | set { this.date_submittedFieldSpecified = value; }
60 | }
61 |
62 | public System.DateTime last_modified {
63 | get { return this.last_modifiedField; }
64 | set { this.last_modifiedField = value; }
65 | }
66 |
67 | [System.Xml.Serialization.SoapIgnoreAttribute()]
68 | public bool last_modifiedSpecified {
69 | get { return this.last_modifiedFieldSpecified; }
70 | set { this.last_modifiedFieldSpecified = value; }
71 | }
72 |
73 | [System.Xml.Serialization.SoapElementAttribute(DataType = "integer")]
74 | public string time_tracking {
75 | get { return this.time_trackingField; }
76 | set { this.time_trackingField = value; }
77 | }
78 |
79 | [System.Xml.Serialization.SoapElementAttribute(DataType = "integer")]
80 | public string note_type {
81 | get { return this.note_typeField; }
82 | set { this.note_typeField = value; }
83 | }
84 |
85 | public string note_attr {
86 | get { return this.note_attrField; }
87 | set { this.note_attrField = value; }
88 | }
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/NBug/Core/Submission/Tracker/Mantis/MantisConnectService.cs:
--------------------------------------------------------------------------------
1 | namespace NBug.Core.Submission.Tracker.Mantis
2 | {
3 |
4 | public class MantisConnectService : System.ServiceModel.ClientBase, IMantisConnectService
5 | {
6 |
7 | public MantisConnectService(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : base(binding, remoteAddress)
8 | {
9 | }
10 |
11 | public string mc_version()
12 | {
13 | return base.Channel.mc_version();
14 | }
15 |
16 | public UserData mc_login(string username, string password)
17 | {
18 | return base.Channel.mc_login(username, password);
19 | }
20 |
21 | public string mc_issue_add(string username, string password, IssueData issue)
22 | {
23 | return base.Channel.mc_issue_add(username, password, issue);
24 | }
25 |
26 | public string mc_project_get_id_from_name(string username, string password, string project_name)
27 | {
28 | return base.Channel.mc_project_get_id_from_name(username, password, project_name);
29 | }
30 |
31 | public string[] mc_project_get_categories(string username, string password, string project_id)
32 | {
33 | return base.Channel.mc_project_get_categories(username, password, project_id);
34 | }
35 |
36 | public string mc_issue_attachment_add(string username, string password, string issue_id, string name, string file_type, byte[] content)
37 | {
38 | return base.Channel.mc_issue_attachment_add(username, password, issue_id, name, file_type, content);
39 | }
40 |
41 | public ProjectVersionData[] mc_project_get_versions(string username, string password, string project_id)
42 | {
43 | return base.Channel.mc_project_get_versions(username, password, project_id);
44 | }
45 |
46 | public string mc_project_version_add(string username, string password, ProjectVersionData version)
47 | {
48 | return base.Channel.mc_project_version_add(username, password, version);
49 | }
50 | }
51 |
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/NBug/Core/Submission/Tracker/Mantis/ObjectRef.cs:
--------------------------------------------------------------------------------
1 | namespace NBug.Core.Submission.Tracker.Mantis
2 | {
3 | [System.SerializableAttribute(), System.Xml.Serialization.SoapTypeAttribute(Namespace = "http://futureware.biz/mantisconnect")]
4 | public class ObjectRef
5 | {
6 |
7 | private string idField;
8 |
9 | private string nameField;
10 | [System.Xml.Serialization.SoapElementAttribute(DataType = "integer")]
11 | public string id {
12 | get { return this.idField; }
13 | set { this.idField = value; }
14 | }
15 |
16 | public string name {
17 | get { return this.nameField; }
18 | set { this.nameField = value; }
19 | }
20 |
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/NBug/Core/Submission/Tracker/Mantis/ProjectVersionData.cs:
--------------------------------------------------------------------------------
1 | namespace NBug.Core.Submission.Tracker.Mantis
2 | {
3 |
4 | [System.SerializableAttribute(),
5 | System.Xml.Serialization.SoapTypeAttribute(Namespace = "http://futureware.biz/mantisconnect")]
6 | public class ProjectVersionData
7 | {
8 |
9 | private string idField;
10 |
11 | private string nameField;
12 |
13 | private string project_idField;
14 |
15 | private System.DateTime date_orderField;
16 |
17 | private bool date_orderFieldSpecified;
18 |
19 | private string descriptionField;
20 |
21 | private bool releasedField;
22 |
23 | private bool releasedFieldSpecified;
24 |
25 | private bool obsoleteField;
26 |
27 | private bool obsoleteFieldSpecified;
28 |
29 | [System.Xml.Serialization.SoapElementAttribute(DataType = "integer")]
30 | public string id
31 | {
32 | get { return this.idField; }
33 | set { this.idField = value; }
34 | }
35 |
36 | public string name
37 | {
38 | get { return this.nameField; }
39 | set { this.nameField = value; }
40 | }
41 |
42 | [System.Xml.Serialization.SoapElementAttribute(DataType = "integer")]
43 | public string project_id
44 | {
45 | get { return this.project_idField; }
46 | set { this.project_idField = value; }
47 | }
48 |
49 | public System.DateTime date_order
50 | {
51 | get { return this.date_orderField; }
52 | set { this.date_orderField = value; }
53 | }
54 |
55 | [System.Xml.Serialization.SoapIgnoreAttribute()]
56 | public bool date_orderSpecified
57 | {
58 | get { return this.date_orderFieldSpecified; }
59 | set { this.date_orderFieldSpecified = value; }
60 | }
61 |
62 | public string description
63 | {
64 | get { return this.descriptionField; }
65 | set { this.descriptionField = value; }
66 | }
67 |
68 | public bool released
69 | {
70 | get { return this.releasedField; }
71 | set { this.releasedField = value; }
72 | }
73 |
74 | [System.Xml.Serialization.SoapIgnoreAttribute()]
75 | public bool releasedSpecified
76 | {
77 | get { return this.releasedFieldSpecified; }
78 | set { this.releasedFieldSpecified = value; }
79 | }
80 |
81 | public bool obsolete
82 | {
83 | get { return this.obsoleteField; }
84 | set { this.obsoleteField = value; }
85 | }
86 |
87 | [System.Xml.Serialization.SoapIgnoreAttribute()]
88 | public bool obsoleteSpecified
89 | {
90 | get { return this.obsoleteFieldSpecified; }
91 | set { this.obsoleteFieldSpecified = value; }
92 | }
93 | }
94 | }
95 |
96 |
97 |
--------------------------------------------------------------------------------
/NBug/Core/Submission/Tracker/Mantis/RelationshipData.cs:
--------------------------------------------------------------------------------
1 | namespace NBug.Core.Submission.Tracker.Mantis
2 | {
3 | [System.SerializableAttribute(), System.Xml.Serialization.SoapTypeAttribute(Namespace = "http://futureware.biz/mantisconnect")]
4 | public class RelationshipData
5 | {
6 | private string idField;
7 |
8 | private ObjectRef typeField;
9 |
10 | private string target_idField;
11 | [System.Xml.Serialization.SoapElementAttribute(DataType = "integer")]
12 | public string id {
13 | get { return this.idField; }
14 | set { this.idField = value; }
15 | }
16 |
17 | public ObjectRef type {
18 | get { return this.typeField; }
19 | set { this.typeField = value; }
20 | }
21 |
22 | [System.Xml.Serialization.SoapElementAttribute(DataType = "integer")]
23 | public string target_id {
24 | get { return this.target_idField; }
25 | set { this.target_idField = value; }
26 | }
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/NBug/Core/Submission/Tracker/Mantis/UserData.cs:
--------------------------------------------------------------------------------
1 | namespace NBug.Core.Submission.Tracker.Mantis
2 | {
3 | [System.SerializableAttribute(), System.Xml.Serialization.SoapTypeAttribute(Namespace = "http://futureware.biz/mantisconnect")]
4 | public class UserData
5 | {
6 |
7 | private AccountData account_dataField;
8 | private string access_levelField;
9 |
10 | private string timezoneField;
11 | public AccountData account_data {
12 | get { return this.account_dataField; }
13 | set { this.account_dataField = value; }
14 | }
15 |
16 | [System.Xml.Serialization.SoapElementAttribute(DataType = "integer")]
17 | public string access_level {
18 | get { return this.access_levelField; }
19 | set { this.access_levelField = value; }
20 | }
21 |
22 | public string timezone {
23 | get { return this.timezoneField; }
24 | set { this.timezoneField = value; }
25 | }
26 |
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/NBug/Core/Submission/Tracker/Mantis/nusoap.php.patch:
--------------------------------------------------------------------------------
1 | --- nusoap.php.org 2013-11-12 14:04:05.000000000 +0100
2 | +++ nusoap.php 2013-11-08 21:13:00.000000000 +0100
3 | @@ -148,8 +148,8 @@
4 | * @var string
5 | * @access public
6 | */
7 | - var $soap_defencoding = 'ISO-8859-1';
8 | - //var $soap_defencoding = 'UTF-8';
9 | + //var $soap_defencoding = 'ISO-8859-1';
10 | + var $soap_defencoding = 'UTF-8';
11 |
12 | /**
13 | * namespaces in an array of prefix => uri
14 | @@ -1052,24 +1052,24 @@
15 | * @return string The serialization of the fault instance.
16 | * @access public
17 | */
18 | - function serialize(){
19 | - $ns_string = '';
20 | - foreach($this->namespaces as $k => $v){
21 | - $ns_string .= "\n xmlns:$k=\"$v\"";
22 | - }
23 | - $return_msg =
24 | - 'soap_defencoding.'"?>'.
25 | - '\n".
26 | - ''.
27 | - ''.
28 | - $this->serialize_val($this->faultcode, 'faultcode').
29 | - $this->serialize_val($this->faultactor, 'faultactor').
30 | - $this->serialize_val($this->faultstring, 'faultstring').
31 | - $this->serialize_val($this->faultdetail, 'detail').
32 | - ''.
33 | - ''.
34 | - '';
35 | - return $return_msg;
36 | + function serialize() {
37 | + $ns_string = '';
38 | + foreach( $this->namespaces as $k => $v ) {
39 | + $ns_string .= "\n xmlns:$k=\"$v\"";
40 | + }
41 | + $return_msg =
42 | + 'soap_defencoding . '"?>' .
43 | + '\n" .
44 | + '' .
45 | + '' .
46 | + $this->serialize_val( $this->faultcode, 'faultcode' ) .
47 | + $this->serialize_val( $this->faultstring, 'faultstring' ) .
48 | + $this->serialize_val( $this->faultactor, 'faultactor' ) .
49 | + $this->serialize_val( $this->faultdetail, 'detail' ) .
50 | + '' .
51 | + '' .
52 | + '';
53 | + return $return_msg;
54 | }
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/NBug/Core/Submission/Tracker/Trac.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Submission.Tracker
8 | {
9 | using System.IO;
10 |
11 | using NBug.Core.Reporting.Info;
12 | using NBug.Core.Util.Serialization;
13 |
14 | internal class Trac : ProtocolBase
15 | {
16 | protected Trac(string connectionString)
17 | : base(connectionString)
18 | {
19 | }
20 |
21 | // Connection string format (single line)
22 | // Warning: There should be no semicolon (;) or equals sign (=) used in any field except for password
23 | // Warning: No field value value should contain the phrase 'password='
24 | // Warning: XML-RPC.NET assembly should be referenced
25 | // Note: Url should be a full url without a trailing slash (/), like: http://......
26 | // Note: Anononymous URL is: http://trac-hacks.org/xmlrpc and authenticated URL is: http://trac-hacks.org/login/xmlrpc
27 |
28 | /* Type=Trac;
29 | * Url=http://tracker.mydomain.com/xmlrpc;
30 | */
31 | public override bool Send(string fileName, Stream file, Report report, SerializableException exception)
32 | {
33 | // ToDo: Check to see if XML-RPC.NET is referenced and if not, show a developer UI as a waning -or- even better, dynamically load the assembly and use that and not the referenced one!
34 | return true;
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/NBug/Core/Submission/Web/Ftp.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Submission.Web
8 | {
9 | using System;
10 | using System.IO;
11 | using System.Net;
12 |
13 | using NBug.Core.Reporting.Info;
14 | using NBug.Core.Util.Logging;
15 | using NBug.Core.Util.Serialization;
16 |
17 | internal class FtpFactory : IProtocolFactory
18 | {
19 | public string SupportedType
20 | {
21 | get
22 | {
23 | return "Ftp";
24 | }
25 | }
26 |
27 | public IProtocol FromConnectionString(string connectionString)
28 | {
29 | return new Ftp(connectionString);
30 | }
31 | }
32 |
33 | public class Ftp : ProtocolBase
34 | {
35 | public Ftp(string connectionString)
36 | : base(connectionString)
37 | {
38 | }
39 |
40 | public Ftp()
41 | {
42 | }
43 |
44 | public string Password { get; set; }
45 |
46 | // Connection string format (single line)
47 | // Warning: There should be no semicolon (;) or equals sign (=) used in any field except for password.
48 | // Warning: No field value should contain the phrase 'password='
49 | // Note: Url should be a full url with a trailing slash (/), like: ftp://....../
50 |
51 | /* Type=FTP;
52 | * Url=ftp://tracker.mydomain.com/myproject/;
53 | * UseSSL=false;
54 | * Username=;
55 | * Password=;
56 | */
57 | public string Url { get; set; }
58 |
59 | public string Username { get; set; }
60 |
61 | public string Usessl { get; set; }
62 |
63 | public override bool Send(string fileName, Stream file, Report report, SerializableException exception)
64 | {
65 | var request = (FtpWebRequest)WebRequest.Create(new Uri(this.Url + fileName));
66 |
67 | if (!string.IsNullOrEmpty(this.Usessl))
68 | {
69 | request.EnableSsl = Convert.ToBoolean(this.Usessl.ToLower());
70 | }
71 |
72 | if (!string.IsNullOrEmpty(this.Username))
73 | {
74 | request.Credentials = new NetworkCredential(this.Username, this.Password);
75 | }
76 |
77 | request.Method = WebRequestMethods.Ftp.UploadFile;
78 | request.Proxy = null; // Otherwise we'll get an exception: The requested FTP command is not supported when a HTTP proxy is used
79 |
80 | using (var requestStream = request.GetRequestStream())
81 | {
82 | file.Position = 0;
83 | file.CopyTo(requestStream);
84 | file.Position = 0;
85 | }
86 |
87 | using (var response = (FtpWebResponse)request.GetResponse())
88 | using (var reader = new StreamReader(response.GetResponseStream()))
89 | {
90 | var responseString = reader.ReadToEnd(); // Null on successful transfer
91 | if (!string.IsNullOrEmpty(responseString))
92 | {
93 | Logger.Info("Response from FTP server: " + responseString);
94 | }
95 |
96 | Logger.Info("Response from FTP server: " + response.StatusDescription);
97 | }
98 |
99 | return true;
100 | }
101 | }
102 | }
--------------------------------------------------------------------------------
/NBug/Core/Submission/Web/Http.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Submission.Web
8 | {
9 | using System.IO;
10 |
11 | using NBug.Core.Reporting.Info;
12 | using NBug.Core.Util.Logging;
13 | using NBug.Core.Util.Serialization;
14 | using NBug.Core.Util.Web;
15 |
16 | public class HttpFactory : IProtocolFactory
17 | {
18 | public string SupportedType
19 | {
20 | get
21 | {
22 | return "Http";
23 | }
24 | }
25 |
26 | public IProtocol FromConnectionString(string connectionString)
27 | {
28 | return new Http(connectionString);
29 | }
30 | }
31 |
32 | public class Http : ProtocolBase
33 | {
34 | public Http(string connectionString)
35 | : base(connectionString)
36 | {
37 | }
38 |
39 | public Http()
40 | {
41 | }
42 |
43 | // Connection string format (single line)
44 | // Warning: There should be no semicolon (;) or equals sign (=) used in any field.
45 | // Note: Url should be a full url with a trailing slash (/) or file extension (i.e. .php), like: http://....../ -or- http://....../upload.php
46 |
47 | /* Type=Http;
48 | * Url=http://tracker.mydomain.com/myproject/upload.php;
49 | */
50 | public string Url { get; set; }
51 |
52 | public override bool Send(string fileName, Stream file, Report report, SerializableException exception)
53 | {
54 | // Advanced method with ability to post variables along with file (do not forget to urlencode the query parameters)
55 | // http://www.codeproject.com/KB/cs/uploadfileex.aspx
56 | // http://stackoverflow.com/questions/566462/upload-files-with-httpwebrequest-multipart-form-data
57 | // http://stackoverflow.com/questions/767790/how-do-i-upload-an-image-file-using-a-post-request-in-c
58 | // http://netomatix.com/HttpPostData.aspx
59 |
60 | /* upload.php file my look like the one below (note that uploaded files are not statically named in this case script may need modification)
61 | *
62 | *
80 | */
81 | file.Position = 0;
82 |
83 | var response = StreamUpload.Create().Add(file, "file", fileName, "application/zip").Upload(this.Url).Response();
84 |
85 | Logger.Info("Response from HTTP server: " + response);
86 | file.Position = 0;
87 |
88 | return true;
89 | }
90 | }
91 | }
--------------------------------------------------------------------------------
/NBug/Core/UI/Console/ConsoleUI.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.UI.Console
8 | {
9 | using System;
10 |
11 | using NBug.Core.Reporting.Info;
12 | using NBug.Core.Util.Exceptions;
13 | using NBug.Core.Util.Serialization;
14 | using NBug.Enums;
15 |
16 | internal static class ConsoleUI
17 | {
18 | internal static UIDialogResult ShowDialog(UIMode uiMode, SerializableException exception, Report report)
19 | {
20 | if (uiMode == UIMode.Minimal)
21 | {
22 | // Do not interact with the user
23 | Console.WriteLine(Environment.NewLine + Settings.Resources.UI_Console_Minimal_Message);
24 | return new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send);
25 | }
26 | else if (uiMode == UIMode.Normal)
27 | {
28 | // ToDo: Create normal console UI
29 | Console.WriteLine(Environment.NewLine + Settings.Resources.UI_Console_Normal_Message);
30 | return new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send);
31 | }
32 | else if (uiMode == UIMode.Full)
33 | {
34 | // ToDo: Create full console UI
35 | Console.WriteLine(Environment.NewLine + Settings.Resources.UI_Console_Full_Message);
36 | return new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send);
37 | }
38 | else
39 | {
40 | throw NBugConfigurationException.Create(() => Settings.UIMode, "Parameter supplied for settings property is invalid.");
41 | }
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/NBug/Core/UI/Custom/CustomUI.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.UI.Custom
8 | {
9 | using NBug.Core.Reporting.Info;
10 | using NBug.Core.Util.Exceptions;
11 | using NBug.Core.Util.Serialization;
12 | using NBug.Enums;
13 | using NBug.Events;
14 |
15 | ///
16 | /// This class is used to prevent statically referencing any WPF dlls from the UISelector.cs thus prevents
17 | /// any unnecessary assembly from getting loaded into the memory.
18 | ///
19 | internal static class CustomUI
20 | {
21 | internal static UIDialogResult ShowDialog(UIMode uiMode, SerializableException exception, Report report)
22 | {
23 | if (Settings.CustomUIHandle != null)
24 | {
25 | var e = new CustomUIEventArgs(uiMode, exception, report);
26 | Settings.CustomUIHandle.DynamicInvoke(null, e);
27 | return e.Result;
28 | }
29 | else
30 | {
31 | throw NBugConfigurationException.Create(() => Settings.UIMode, "Parameter supplied for settings property is invalid.");
32 | }
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/NBug/Core/UI/Developer/InternalLogViewer.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.UI.Developer
8 | {
9 | using System;
10 | using System.Threading;
11 | using System.Threading.Tasks;
12 | using System.Windows.Forms;
13 |
14 | using NBug.Enums;
15 | using NBug.Properties;
16 |
17 | internal partial class InternalLogViewer : Form
18 | {
19 | private static bool closed;
20 |
21 | private static ManualResetEvent handleCreated;
22 |
23 | private static bool initialized;
24 |
25 | private static InternalLogViewer viewer;
26 |
27 | internal InternalLogViewer()
28 | {
29 | this.InitializeComponent();
30 | this.Icon = Resources.NBug_icon_16;
31 | this.notifyIcon.Icon = Resources.NBug_icon_16;
32 | }
33 |
34 | public static void InitializeInternalLogViewer()
35 | {
36 | if (!initialized)
37 | {
38 | initialized = true;
39 | viewer = new InternalLogViewer();
40 | handleCreated = new ManualResetEvent(false);
41 | viewer.HandleCreated += (sender, e) => handleCreated.Set();
42 | Task.Factory.StartNew(() => Application.Run(viewer));
43 | handleCreated.WaitOne();
44 | }
45 | }
46 |
47 | public static void LogEntry(string message, LoggerCategory category)
48 | {
49 | InitializeInternalLogViewer();
50 |
51 | if (!closed)
52 | {
53 | viewer.Invoke((MethodInvoker)(() => viewer.InternalLogEntry(message, category)));
54 | }
55 | }
56 |
57 | internal void InternalLogEntry(string message, LoggerCategory category)
58 | {
59 | this.loggerListView.Items.Add(new ListViewItem(new[] { category.ToString().Remove(0, 4), DateTime.Now.ToString("HH:mm:ss"), message }));
60 | }
61 |
62 | private void HideButton_Click(object sender, EventArgs e)
63 | {
64 | this.Hide();
65 | }
66 |
67 | private void InternalLogViewer_Resize(object sender, EventArgs e)
68 | {
69 | if (this.WindowState == FormWindowState.Minimized)
70 | {
71 | this.Hide();
72 | }
73 | }
74 |
75 | private void LoggerListView_Click(object sender, EventArgs e)
76 | {
77 | this.detailsTextBox.Text = this.loggerListView.SelectedItems[0].SubItems[2].Text;
78 | }
79 |
80 | private void NotifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)
81 | {
82 | if (this.WindowState == FormWindowState.Minimized)
83 | {
84 | this.WindowState = FormWindowState.Normal;
85 | }
86 |
87 | this.Show();
88 | this.Activate();
89 | }
90 |
91 | private void QuitButton_Click(object sender, EventArgs e)
92 | {
93 | this.notifyIcon.Visible = false;
94 | this.notifyIcon.Dispose();
95 | this.notifyIcon = null;
96 | closed = true;
97 | this.Close();
98 | }
99 | }
100 | }
--------------------------------------------------------------------------------
/NBug/Core/UI/UIDialogResult.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.UI
8 | {
9 | public enum SendReport
10 | {
11 | Send,
12 |
13 | DoNotSend
14 | }
15 |
16 | public enum ExecutionFlow
17 | {
18 | ///
19 | /// This will handle all unhandled exceptions to be able to continue execution.
20 | ///
21 | ContinueExecution,
22 |
23 | ///
24 | /// This will handle all unhandled exceptions and exit the application.
25 | ///
26 | BreakExecution,
27 | }
28 |
29 | public struct UIDialogResult
30 | {
31 | internal ExecutionFlow Execution;
32 |
33 | internal SendReport Report;
34 |
35 | public UIDialogResult(ExecutionFlow execution, SendReport report)
36 | {
37 | this.Execution = execution;
38 | this.Report = report;
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/NBug/Core/UI/WPF/WPFUI.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.UI.WPF
8 | {
9 | using NBug.Core.Reporting.Info;
10 | using NBug.Core.UI.WinForms;
11 | using NBug.Core.Util.Exceptions;
12 | using NBug.Core.Util.Serialization;
13 | using NBug.Enums;
14 |
15 | ///
16 | /// This class is used to prevent statically referencing any WPF dlls from the UISelector.cs thus prevents
17 | /// any unnecessary assembly from getting loaded into the memory.
18 | ///
19 | internal static class WPFUI
20 | {
21 | internal static UIDialogResult ShowDialog(UIMode uiMode, SerializableException exception, Report report)
22 | {
23 | if (uiMode == UIMode.Minimal)
24 | {
25 | // ToDo: Create WPF dialogs
26 | return new Minimal().ShowDialog(report);
27 | }
28 | else if (uiMode == UIMode.Normal)
29 | {
30 | // ToDo: Create WPF dialogs
31 | using (var ui = new Normal())
32 | {
33 | return ui.ShowDialog(report);
34 | }
35 | }
36 | else if (uiMode == UIMode.Full)
37 | {
38 | // ToDo: Create WPF dialogs
39 | using (var ui = new Full())
40 | {
41 | return ui.ShowDialog(exception, report);
42 | }
43 | }
44 | else
45 | {
46 | throw NBugConfigurationException.Create(() => Settings.UIMode, "Parameter supplied for settings property is invalid.");
47 | }
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/NBug/Core/UI/WinForms/Feedback.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.UI.WinForms
8 | {
9 | using System.Windows.Forms;
10 |
11 | using NBug.Properties;
12 |
13 | internal partial class Feedback : Form
14 | {
15 | public Feedback()
16 | {
17 | this.InitializeComponent();
18 | this.Icon = Resources.NBug_icon_16;
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/NBug/Core/UI/WinForms/Full.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.UI.WinForms
8 | {
9 | using System;
10 | using System.Drawing;
11 | using System.Windows.Forms;
12 |
13 | using NBug.Core.Reporting.Info;
14 | using NBug.Core.Util.Serialization;
15 | using NBug.Properties;
16 |
17 | using Settings = NBug.Settings;
18 |
19 | internal partial class Full : Form
20 | {
21 | private UIDialogResult uiDialogResult;
22 |
23 | internal Full()
24 | {
25 | this.InitializeComponent();
26 | this.Icon = Resources.NBug_icon_16;
27 | this.warningLabel.Text = Settings.Resources.UI_Dialog_Full_Message;
28 | this.generalTabPage.Text = Settings.Resources.UI_Dialog_Full_General_Tab;
29 | this.exceptionTabPage.Text = Settings.Resources.UI_Dialog_Full_Exception_Tab;
30 | this.reportContentsTabPage.Text = Settings.Resources.UI_Dialog_Full_Report_Contents_Tab;
31 | this.errorDescriptionLabel.Text = Settings.Resources.UI_Dialog_Full_How_to_Reproduce_the_Error_Notification;
32 | this.quitButton.Text = Settings.Resources.UI_Dialog_Full_Quit_Button;
33 | this.sendAndQuitButton.Text = Settings.Resources.UI_Dialog_Full_Send_and_Quit_Button;
34 |
35 | // ToDo: Displaying report contents properly requires some more work.
36 | this.mainTabs.TabPages.Remove(this.mainTabs.TabPages["reportContentsTabPage"]);
37 | }
38 |
39 | internal UIDialogResult ShowDialog(SerializableException exception, Report report)
40 | {
41 | this.Text = string.Format("{0} {1}", report.GeneralInfo.HostApplication, Settings.Resources.UI_Dialog_Full_Title);
42 |
43 | // Fill in the 'General' tab
44 | this.warningPictureBox.Image = SystemIcons.Warning.ToBitmap();
45 | this.exceptionTextBox.Text = exception.Type;
46 | this.exceptionMessageTextBox.Text = exception.Message;
47 | this.targetSiteTextBox.Text = exception.TargetSite;
48 | this.applicationTextBox.Text = report.GeneralInfo.HostApplication + " [" + report.GeneralInfo.HostApplicationVersion + "]";
49 | this.nbugTextBox.Text = report.GeneralInfo.NBugVersion;
50 | this.dateTimeTextBox.Text = report.GeneralInfo.DateTime;
51 | this.clrTextBox.Text = report.GeneralInfo.CLRVersion;
52 |
53 | // Fill in the 'Exception' tab
54 | this.exceptionDetails.Initialize(exception);
55 |
56 | // ToDo: Fill in the 'Report Contents' tab);
57 | this.ShowDialog();
58 |
59 | // Write back the user description (as we passed 'report' as a reference since it is a refence object anyway)
60 | report.GeneralInfo.UserDescription = this.descriptionTextBox.Text;
61 | return this.uiDialogResult;
62 | }
63 |
64 | private void QuitButton_Click(object sender, EventArgs e)
65 | {
66 | this.uiDialogResult = new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.DoNotSend);
67 | this.Close();
68 | }
69 |
70 | private void ReportContentsTabPage_Enter(object sender, EventArgs e)
71 | {
72 | /*using (Storer storer = new Storer())
73 | using (ZipStorer zipStorer = ZipStorer.Open(storer.GetFirstReportFile(), FileAccess.Read))
74 | using (Stream zipItemStream = new MemoryStream())
75 | {
76 | List zipDirectory = zipStorer.ReadCentralDir();
77 |
78 | foreach (ZipStorer.ZipFileEntry entry in zipDirectory)
79 | {
80 | zipItemStream.SetLength(0);
81 | zipStorer.ExtractFile(entry, zipItemStream);
82 | zipItemStream.Position = 0;
83 | this.reportContentsListView.Items.Add(entry.FilenameInZip);
84 | }
85 | }*/
86 | }
87 |
88 | private void SendAndQuitButton_Click(object sender, EventArgs e)
89 | {
90 | this.uiDialogResult = new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send);
91 | this.Close();
92 | }
93 | }
94 | }
--------------------------------------------------------------------------------
/NBug/Core/UI/WinForms/Minimal.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | using System.Configuration;
8 |
9 | namespace NBug.Core.UI.WinForms
10 | {
11 | using System.Windows.Forms;
12 |
13 | using NBug.Core.Reporting.Info;
14 |
15 | internal class Minimal
16 | {
17 | internal UIDialogResult ShowDialog(Report report)
18 | {
19 | MessageBox.Show(
20 | new Form { TopMost = true },
21 | Settings.Resources.UI_Dialog_Minimal_Message,
22 | report.GeneralInfo.HostApplication + " " + Properties.Localization.UI_Dialog_Minimal_Title,
23 | MessageBoxButtons.OK,
24 | MessageBoxIcon.Warning);
25 |
26 | return new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send);
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/NBug/Core/UI/WinForms/Normal.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.UI.WinForms
8 | {
9 | using System;
10 | using System.Drawing;
11 | using System.Windows.Forms;
12 |
13 | using NBug.Core.Reporting.Info;
14 | using NBug.Properties;
15 |
16 | using Settings = NBug.Settings;
17 |
18 | internal partial class Normal : Form
19 | {
20 | private UIDialogResult uiDialogResult;
21 |
22 | internal Normal()
23 | {
24 | this.InitializeComponent();
25 | this.Icon = Resources.NBug_icon_16;
26 | this.warningPictureBox.Image = SystemIcons.Warning.ToBitmap();
27 | this.warningLabel.Text = Settings.Resources.UI_Dialog_Normal_Message;
28 | this.continueButton.Text = Settings.Resources.UI_Dialog_Normal_Continue_Button;
29 | this.quitButton.Text = Settings.Resources.UI_Dialog_Normal_Quit_Button;
30 | }
31 |
32 | internal UIDialogResult ShowDialog(Report report)
33 | {
34 | this.Text = string.Format("{0} {1}", report.GeneralInfo.HostApplication, Settings.Resources.UI_Dialog_Normal_Title);
35 | this.exceptionMessageLabel.Text = report.GeneralInfo.ExceptionMessage;
36 |
37 | this.ShowDialog();
38 |
39 | return this.uiDialogResult;
40 | }
41 |
42 | private void ContinueButton_Click(object sender, EventArgs e)
43 | {
44 | this.uiDialogResult = new UIDialogResult(ExecutionFlow.ContinueExecution, SendReport.Send);
45 | this.Close();
46 | }
47 |
48 | private void QuitButton_Click(object sender, EventArgs e)
49 | {
50 | this.uiDialogResult = new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send);
51 | this.Close();
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/NBug/Core/UI/WinForms/Panels/ExceptionDetailView.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.UI.WinForms.Panels
8 | {
9 | using System;
10 | using System.Windows.Forms;
11 |
12 | internal partial class ExceptionDetailView : Form
13 | {
14 | public ExceptionDetailView()
15 | {
16 | this.InitializeComponent();
17 | }
18 |
19 | internal void ShowDialog(string property, string info)
20 | {
21 | this.propertyTextBox.Text = property;
22 | this.propertyInformationTextBox.Text = info;
23 | this.ShowDialog();
24 | }
25 |
26 | private void CloseButton_Click(object sender, EventArgs e)
27 | {
28 | this.Close();
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/NBug/Core/UI/WinForms/WinFormsUI.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.UI.WinForms
8 | {
9 | using NBug.Core.Reporting.Info;
10 | using NBug.Core.Util.Exceptions;
11 | using NBug.Core.Util.Serialization;
12 | using NBug.Enums;
13 |
14 | ///
15 | /// This class is used to prevent statically referencing any WinForms dll from the UISelector.cs thus prevents
16 | /// any unnecessary assembly from getting loaded into the memory.
17 | ///
18 | internal static class WinFormsUI
19 | {
20 | internal static UIDialogResult ShowDialog(UIMode uiMode, SerializableException exception, Report report)
21 | {
22 | if (uiMode == UIMode.Minimal)
23 | {
24 | return new Minimal().ShowDialog(report);
25 | }
26 | else if (uiMode == UIMode.Normal)
27 | {
28 | using (var ui = new Normal())
29 | {
30 | return ui.ShowDialog(report);
31 | }
32 | }
33 | else if (uiMode == UIMode.Full)
34 | {
35 | using (var ui = new Full())
36 | {
37 | return ui.ShowDialog(exception, report);
38 | }
39 | }
40 | else
41 | {
42 | throw NBugConfigurationException.Create(() => Settings.UIMode, "Parameter supplied for settings property is invalid.");
43 | }
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/NBug/Core/Util/ConnectionStringParser.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Util
8 | {
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Text.RegularExpressions;
12 |
13 | using NBug.Core.Util.Exceptions;
14 |
15 | public static class ConnectionStringParser
16 | {
17 | // Currently ; and = characters are illegal and needs preparsing and escaping
18 | public static Dictionary Parse(string connectionString)
19 | {
20 | try
21 | {
22 | // Pre-processing the connection string, detect escape sequence, trim trailing semicolon
23 | var data = new Dictionary();
24 | var fields = Regex.Split(connectionString.TrimEnd(new[] { ';' }), @"(?
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Util
8 | {
9 | internal enum ExceptionThread
10 | {
11 | Main,
12 |
13 | UI_WinForms,
14 |
15 | UI_WPF,
16 |
17 | Task
18 | }
19 | }
--------------------------------------------------------------------------------
/NBug/Core/Util/Exceptions/NBugConfigurationException.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Util.Exceptions
8 | {
9 | using System;
10 | using System.Linq.Expressions;
11 |
12 | [Serializable]
13 | public class NBugConfigurationException : NBugException
14 | {
15 | public NBugConfigurationException(string message, Exception inner)
16 | : base(message, inner)
17 | {
18 | this.MisconfiguredProperty = string.Empty;
19 | }
20 |
21 | private NBugConfigurationException(string propertyName, string message)
22 | : base(message)
23 | {
24 | this.MisconfiguredProperty = propertyName;
25 | }
26 |
27 | public string MisconfiguredProperty { get; set; }
28 |
29 | public static NBugConfigurationException Create(Expression> propertyExpression, string message)
30 | {
31 | return new NBugConfigurationException(((MemberExpression)propertyExpression.Body).Member.Name, message);
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/NBug/Core/Util/Exceptions/NBugException.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Util.Exceptions
8 | {
9 | using System;
10 | using System.Runtime.Serialization;
11 |
12 | [Serializable]
13 | public class NBugException : Exception
14 | {
15 | public NBugException()
16 | {
17 | }
18 |
19 | public NBugException(string message)
20 | : base(message)
21 | {
22 | }
23 |
24 | public NBugException(string message, Exception inner)
25 | : base(message, inner)
26 | {
27 | }
28 |
29 | protected NBugException(SerializationInfo info, StreamingContext context)
30 | : base(info, context)
31 | {
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/NBug/Core/Util/Exceptions/NBugRuntimeException.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Util.Exceptions
8 | {
9 | using System;
10 |
11 | [Serializable]
12 | public class NBugRuntimeException : NBugException
13 | {
14 | public NBugRuntimeException(string message, Exception inner)
15 | : base(message, inner)
16 | {
17 | }
18 |
19 | public NBugRuntimeException(string message)
20 | : base(message)
21 | {
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/NBug/Core/Util/ProtectedConfiguration.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Util
8 | {
9 | internal class ProtectedConfiguration
10 | {
11 | /* Below is used to load custom app.config files:
12 | * System.Configuration.ConfigurationManager.OpenExeConfiguration(string exePath)
13 | */
14 |
15 | /*internal static void ProtectConfiguration()
16 | {
17 | // Get the application configuration file.
18 | Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
19 |
20 | // Get the section to protect.
21 | ConfigurationSection connStrings = config.ConnectionStrings;
22 |
23 | if (connStrings != null)
24 | {
25 | if (!connStrings.SectionInformation.IsProtected)
26 | {
27 | if (!connStrings.ElementInformation.IsLocked)
28 | {
29 | // Protect the section.
30 | connStrings.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
31 |
32 | connStrings.SectionInformation.ForceSave = true;
33 | config.Save(ConfigurationSaveMode.Full);
34 |
35 | Logger.Info(String.Format("Section {0} is now protected by {1}", connStrings.SectionInformation.Name, connStrings.SectionInformation.ProtectionProvider.Name));
36 | }
37 | else
38 | {
39 | Logger.Warning(String.Format("Can't protect, section {0} is locked", connStrings.SectionInformation.Name));
40 | }
41 | }
42 | else
43 | {
44 | Logger.Info(String.Format("Section {0} is already protected by {1}", connStrings.SectionInformation.Name, connStrings.SectionInformation.ProtectionProvider.Name));
45 | }
46 | }
47 | else
48 | {
49 | Logger.Error(String.Format("Can't get the section {0}", connStrings.SectionInformation.Name));
50 | }
51 | }
52 |
53 | ///
54 | /// Restores the unprotected state of the configuration file, connectionStrings section.
55 | ///
56 | /// There is no need to manually decrypt
57 | internal static void UnProtectConfiguration()
58 | {
59 | // Get the application configuration file.
60 | Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
61 |
62 | // Get the section to unprotect.
63 | ConfigurationSection connStrings = config.ConnectionStrings;
64 |
65 | if (connStrings != null)
66 | {
67 | if (connStrings.SectionInformation.IsProtected)
68 | {
69 | if (!connStrings.ElementInformation.IsLocked)
70 | {
71 | // Unprotect the section.
72 | connStrings.SectionInformation.UnprotectSection();
73 |
74 | connStrings.SectionInformation.ForceSave = true;
75 | config.Save(ConfigurationSaveMode.Full);
76 |
77 | Logger.Info(String.Format("Section {0} is now unprotected.", connStrings.SectionInformation.Name));
78 | }
79 | else
80 | {
81 | Logger.Warning(String.Format("Can't unprotect, section {0} is locked", connStrings.SectionInformation.Name));
82 | }
83 | }
84 | else
85 | {
86 | Logger.Info(String.Format("Section {0} is already unprotected.", connStrings.SectionInformation.Name));
87 | }
88 | }
89 | else
90 | {
91 | Logger.Error(String.Format("Can't get the section {0}", connStrings.SectionInformation.Name));
92 | }
93 | }*/
94 | }
95 | }
--------------------------------------------------------------------------------
/NBug/Core/Util/Serialization/SerializableDictionary.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Util.Serialization
8 | {
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Xml;
12 | using System.Xml.Linq;
13 | using System.Xml.Schema;
14 | using System.Xml.Serialization;
15 |
16 | [Serializable]
17 | [XmlRoot("dictionary")]
18 | public class SerializableDictionary : Dictionary, IXmlSerializable
19 | {
20 | ///
21 | /// Initializes a new instance of the class.
22 | /// This is the default constructor provided for XML serializer.
23 | ///
24 | public SerializableDictionary()
25 | {
26 | }
27 |
28 | public SerializableDictionary(IDictionary dictionary)
29 | {
30 | if (dictionary == null)
31 | {
32 | throw new ArgumentNullException();
33 | }
34 |
35 | foreach (var pair in dictionary)
36 | {
37 | this.Add(pair.Key, pair.Value);
38 | }
39 | }
40 |
41 | public XmlSchema GetSchema()
42 | {
43 | return null;
44 | }
45 |
46 | public void ReadXml(XmlReader reader)
47 | {
48 | /*if (reader.IsEmptyElement)
49 | {
50 | return;
51 | }*/
52 | var inner = reader.ReadSubtree();
53 |
54 | var xElement = XElement.Load(inner);
55 | if (xElement.HasElements)
56 | {
57 | foreach (var element in xElement.Elements())
58 | {
59 | this.Add((TKey)Convert.ChangeType(element.Name.ToString(), typeof(TKey)), (TValue)Convert.ChangeType(element.Value, typeof(TValue)));
60 | }
61 | }
62 |
63 | inner.Close();
64 |
65 | reader.ReadEndElement();
66 | }
67 |
68 | public void WriteXml(XmlWriter writer)
69 | {
70 | foreach (var key in this.Keys)
71 | {
72 | writer.WriteStartElement(key.ToString().Replace(" ", ""));
73 | // Check to see if we can actually serialize element
74 | if (this[key].GetType().IsSerializable)
75 | {
76 | // if it's Serializable doesn't mean serialization will succeed (IE. GUID and SQLError types)
77 | try
78 | {
79 | writer.WriteValue(this[key]);
80 | }
81 | catch (Exception)
82 | {
83 | // we're not Throwing anything here, otherwise evil thing will happen
84 | writer.WriteValue(this[key].ToString());
85 | }
86 | }
87 | else
88 | {
89 | // If Type has custom implementation of ToString() we'll get something useful here
90 | // Otherwise we'll get Type string. (Still better than crashing).
91 | writer.WriteValue(this[key].ToString());
92 | }
93 | writer.WriteEndElement();
94 | }
95 | }
96 |
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/NBug/Core/Util/Storage/FileMask.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace NBug.Core.Util.Storage
8 | {
9 | public class FileMask
10 | {
11 | ///
12 | /// Gets or sets a the file path. The files can use * or ? in the same way as DOS modifiers.
13 | ///
14 | public string FilePath { get; set; }
15 |
16 | ///
17 | /// Gets or sets the the kind of access other processes can have access to the file white it's being zipped for the report.
18 | /// Defaults to FileShare.Read but other files might require FileShare.ReadWrite
19 | /// (i.e. log4net log files that are constantly open and can only be access with FileShare.ReadWrite).
20 | ///
21 | public FileShare FileShare { get; set; }
22 |
23 | public FileMask(String path)
24 | {
25 | this.FilePath = path;
26 | FileShare = FileShare.Read;
27 | }
28 |
29 | public static implicit operator String(FileMask o)
30 | {
31 | return o == null ? null : o.FilePath;
32 | }
33 |
34 | public static implicit operator FileMask(String o)
35 | {
36 | return o == null ? null : new FileMask(o);
37 | }
38 |
39 | ///
40 | /// Add all additional files represented by this instance to the zip file using the zipStorer
41 | ///
42 | ///
43 | internal void AddToZip(ZipStorer zipStorer)
44 | {
45 | // Join before spliting because the mask may have some folders inside it
46 | var fullPath = Path.Combine(Settings.NBugDirectory, FilePath);
47 | var dir = Path.GetDirectoryName(fullPath);
48 | var file = Path.GetFileName(fullPath);
49 |
50 | if (!Directory.Exists(dir))
51 | {
52 | return;
53 | }
54 |
55 | if (file.Contains("*") || file.Contains("?"))
56 | {
57 | foreach (var item in Directory.GetFiles(dir, file))
58 | {
59 | this.AddToZip(zipStorer, Settings.NBugDirectory, item, FileShare);
60 | }
61 | }
62 | else
63 | {
64 | this.AddToZip(zipStorer, Settings.NBugDirectory, fullPath, FileShare);
65 | }
66 | }
67 |
68 | // ToDo: PRIORITY TASK! This code needs more testing & condensation
69 | private void AddToZip(ZipStorer zipStorer, string basePath, string path, FileShare share)
70 | {
71 | path = Path.GetFullPath(path);
72 |
73 | // If this is not inside basePath, lets change the basePath so at least some directories are kept
74 | if (!path.StartsWith(basePath))
75 | {
76 | basePath = Path.GetDirectoryName(path);
77 | }
78 |
79 | if (Directory.Exists(path))
80 | {
81 | foreach (var file in Directory.GetFiles(path))
82 | {
83 | this.AddToZip(zipStorer, basePath, file, share);
84 | }
85 |
86 | foreach (var dir in Directory.GetDirectories(path))
87 | {
88 | this.AddToZip(zipStorer, basePath, dir, share);
89 | }
90 | }
91 | else if (File.Exists(path))
92 | {
93 | var nameInZip = path.Substring(basePath.Length);
94 | if (nameInZip.StartsWith("\\") || nameInZip.StartsWith("/"))
95 | {
96 | nameInZip = nameInZip.Substring(1);
97 | }
98 |
99 | nameInZip = Path.Combine("files", nameInZip);
100 |
101 | using (Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare))
102 | {
103 | zipStorer.AddStream(ZipStorer.Compression.Deflate, nameInZip, stream, File.GetLastWriteTime(path), string.Empty);
104 | }
105 | }
106 | }
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/NBug/Core/Util/Storage/StoragePath.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Util.Storage
8 | {
9 | using System;
10 |
11 | ///
12 | /// This structure holds the information about storage path. It does emit its internal data either as string or
13 | /// type according to usage so it must be handled with care.
14 | ///
15 | // ToDo: [TypeConverter(typeof(StoragePath))]
16 | public struct StoragePath
17 | {
18 | private static Enums.StoragePath storagePathEnum;
19 |
20 | private static string storagePathString;
21 |
22 | internal StoragePath(Enums.StoragePath storagePath)
23 | {
24 | storagePathEnum = storagePath;
25 | }
26 |
27 | internal StoragePath(string storagePath)
28 | {
29 | storagePathString = storagePath;
30 | storagePathEnum = Enums.StoragePath.Custom;
31 | }
32 |
33 | public static implicit operator StoragePath(Enums.StoragePath path)
34 | {
35 | return new StoragePath(path);
36 | }
37 |
38 | public static implicit operator StoragePath(string path)
39 | {
40 | foreach (Enums.StoragePath value in Enum.GetValues(typeof(Enums.StoragePath)))
41 | {
42 | if (value.ToString() == path)
43 | {
44 | return new StoragePath(value);
45 | }
46 | }
47 |
48 | return new StoragePath(path);
49 | }
50 |
51 | public static implicit operator Enums.StoragePath(StoragePath path)
52 | {
53 | return storagePathEnum;
54 | }
55 |
56 | public static implicit operator string(StoragePath path)
57 | {
58 | return storagePathString;
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/NBug/Core/Util/Storage/StoredItemFile.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Core.Util.Storage
8 | {
9 | internal enum StoredItemType
10 | {
11 | Exception,
12 |
13 | Report,
14 |
15 | MiniDump
16 | }
17 |
18 | // This class must remain internal otherwise it should not use constant strings
19 | internal static class StoredItemFile
20 | {
21 | internal const string Exception = "Exception.xml";
22 |
23 | internal const string MiniDump = "MiniDump.mdmp";
24 |
25 | internal const string Report = "Report.xml";
26 | }
27 | }
--------------------------------------------------------------------------------
/NBug/Enums/LoggerCategory.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Enums
8 | {
9 | public enum LoggerCategory
10 | {
11 | ///
12 | /// This category outputs most detailed information about the internal state of the library. Every single major event (like
13 | /// generating a bug report, submitting a bug report, truncating internal files, etc.) is logged in this category.
14 | ///
15 | NBugTrace,
16 |
17 | ///
18 | /// This category outputs results of substantial events like the server response after submitting a bug report to the a server.
19 | ///
20 | NBugInfo,
21 |
22 | ///
23 | /// This category outputs warning messages from non-exceptional but important errors like a missing or inaccessable files.
24 | ///
25 | NBugWarning,
26 |
27 | ///
28 | /// This category outputs error messages for exceptional and critical situations. These situations generally disable some functionality
29 | /// of the library or halts the execution of some code path. If not in release mode, an exception is thrown for error messages.
30 | ///
31 | NBugError
32 | }
33 | }
--------------------------------------------------------------------------------
/NBug/Enums/MiniDumpType.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Enums
8 | {
9 | public enum MiniDumpType
10 | {
11 | ///
12 | /// Generate no minidump at all.
13 | ///
14 | None,
15 |
16 | ///
17 | /// Generates the smallest possible minidump still with useful information. Dump size is about ~100KB compressed.
18 | ///
19 | Tiny,
20 |
21 | ///
22 | /// Generates minidump with private read write memory and data segments. This mode allows retreiving of local values and the stack
23 | /// variables. Dump size is about ~5MB compressed.
24 | ///
25 | Normal,
26 |
27 | ///
28 | /// Generates full application memory dump. This simply dump all memory used by the process. Dump size is about ~100MB compressed.
29 | ///
30 | Full
31 | }
32 | }
--------------------------------------------------------------------------------
/NBug/Enums/StoragePath.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Enums
8 | {
9 | public enum StoragePath
10 | {
11 | ///
12 | /// %Temp% directory is the default storage. Usually set to 'C:\Documents and Settings\Username\Local Settings\Temp'.
13 | ///
14 | WindowsTemp,
15 |
16 | ///
17 | /// Initial working directory, i.e. where the executing assembly (MyProduct.exe) is located.
18 | ///
19 | CurrentDirectory,
20 |
21 | ///
22 | /// User's isolated storage store (application scope).
23 | ///
24 | IsolatedStorage,
25 |
26 | ///
27 | /// Custom path should be a full path like 'C:\Documents and Settings\MyUser\Local Settings\Temp'.
28 | ///
29 | /// Path should not have a trailing slash. If the directory doesn't exist, it is created first.
30 | Custom
31 | }
32 | }
--------------------------------------------------------------------------------
/NBug/Enums/UIMode.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Enums
8 | {
9 | public enum UIMode
10 | {
11 | ///
12 | /// Automatic mode selection is the default setting. Mode and provider is automatically selected for different application types.
13 | ///
14 | Auto,
15 |
16 | ///
17 | /// No user interface is displayed at all. All the exception handling and bug reporting process is silent. In this mode, termination of
18 | /// of the host application can be skipped altogether via
19 | ///
20 | None,
21 |
22 | ///
23 | /// Minimal user interface is displayed. This consists of a simple message box for WinForms and WPF, and a single line of information
24 | /// message for console applications.
25 | ///
26 | Minimal,
27 |
28 | ///
29 | /// Normal user interface is displayed to the user, which strikes a balance between the level of details shown about the exception and
30 | /// being still user friendly. This closely replicates the original interface displayed by CLR in case of unhandled exceptions.
31 | ///
32 | Normal,
33 |
34 | ///
35 | /// Full blown user interface is displayed to the user. This interface contains as much detail about the exception and the application
36 | /// as possible. This is very useful for power users.
37 | ///
38 | Full
39 | }
40 | }
--------------------------------------------------------------------------------
/NBug/Enums/UIProvider.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Enums
8 | {
9 | public enum UIProvider
10 | {
11 | ///
12 | /// Automatic provider selection is the default setting.
13 | ///
14 | Auto,
15 |
16 | ///
17 | /// Only the console is used to display the interface and interact with the user if necessary.
18 | ///
19 | Console,
20 |
21 | ///
22 | /// Windows Forms interface is used for all UI displayed to the user.
23 | ///
24 | WinForms,
25 |
26 | ///
27 | /// Windows Presentation Foundation interface is used for all UI displayed to the user.
28 | ///
29 | WPF,
30 |
31 | ///
32 | /// Custom UIProvider.
33 | ///
34 | Custom
35 | }
36 | }
--------------------------------------------------------------------------------
/NBug/Events/CustomSubmissionEventArgs.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Events
8 | {
9 | using System;
10 | using System.IO;
11 |
12 | using NBug.Core.Reporting.Info;
13 | using NBug.Core.Util.Serialization;
14 |
15 | public class CustomSubmissionEventArgs : EventArgs
16 | {
17 | internal CustomSubmissionEventArgs(string fileName, Stream file, Report report, SerializableException exception)
18 | {
19 | this.FileName = fileName;
20 | this.File = file;
21 | this.Report = report;
22 | this.Exception = exception;
23 | this.Result = false;
24 | }
25 |
26 | public SerializableException Exception { get; private set; }
27 |
28 | public Stream File { get; private set; }
29 |
30 | public string FileName { get; private set; }
31 |
32 | public Report Report { get; private set; }
33 |
34 | public bool Result { get; set; }
35 | }
36 | }
--------------------------------------------------------------------------------
/NBug/Events/CustomUIEventArgs.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Events
8 | {
9 | using System;
10 |
11 | using NBug.Core.Reporting.Info;
12 | using NBug.Core.UI;
13 | using NBug.Core.Util.Serialization;
14 | using NBug.Enums;
15 |
16 | public class CustomUIEventArgs : EventArgs
17 | {
18 | internal CustomUIEventArgs(UIMode uiMode, SerializableException exception, Report report)
19 | {
20 | this.UIMode = uiMode;
21 | this.Report = report;
22 | this.Exception = exception;
23 | this.Result = new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.DoNotSend);
24 | }
25 |
26 | public SerializableException Exception { get; private set; }
27 |
28 | public Report Report { get; private set; }
29 |
30 | public UIDialogResult Result { get; set; }
31 |
32 | public UIMode UIMode { get; private set; }
33 | }
34 | }
--------------------------------------------------------------------------------
/NBug/Exceptions.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug
8 | {
9 | using System;
10 |
11 | using NBug.Core.Reporting;
12 | using NBug.Core.Reporting.MiniDump;
13 | using NBug.Core.Util;
14 |
15 | public static class Exceptions
16 | {
17 | ///
18 | /// This function acts as an exception filter for any exception that is raised from within the action body (you can see
19 | /// MSDN subject "Exception Filters" to get more info on the subject). As the name implies, exceptions raised from within
20 | /// the action block is simply filtered to be sent as an error report, and never actually caught or handled. Filters all
21 | /// the exceptions inside the action body and queues an error report. Note that the exceptions are not actually handled,
22 | /// but filtered, so if the exception is left unhandled in an upper block, it will crash the application. This is very
23 | /// useful for situations where you need to log exceptions inside a code block and get a good minidump of the exception.
24 | /// Use the method to actually handle the exception and show an exception dialog to the
25 | /// user and shut down the application gracefully (if set so). You can simply use Filter(() => { MyCodeHere(); })
26 | ///
27 | /// Body of code to be executed.
28 | public static void Filter(Action body)
29 | {
30 | ExceptionFilters.Filter(body, ex => new BugReport().Report(ex, ExceptionThread.Main));
31 | }
32 |
33 | ///
34 | /// Similar to but this time, exceptions are not allowed to escape the action body and they are
35 | /// simply swallowed after being queued for reporting, with a small UI displayed to the user (if set so). Note that
36 | /// NBug can halt the execution with Environment.Exit(0); if you configured it to do so with
37 | /// parameter set to . You can simply use Handle(true, () => { MyCodeHere(); })
38 | ///
39 | /// Decides whether to exit application after handling the exception or continue execution.
40 | /// Body of code to be executed.
41 | public static void Handle(bool continueExecution, Action body)
42 | {
43 | ExceptionFilters.Filter(
44 | body,
45 | ex =>
46 | {
47 | // Filtering the exception
48 | new BugReport().Report(ex, ExceptionThread.Main);
49 | return true; // Yes proceed to handling the exception
50 | },
51 | ex =>
52 | {
53 | if (!continueExecution)
54 | {
55 | Environment.Exit(0);
56 | }
57 | });
58 | }
59 |
60 | ///
61 | /// Submits a bug report for the given exception. This function useful for submitting bug reports inside a try-catch block.
62 | /// Note that this function uses the NBug configuration so it will use the pre-configured UI and submission settings.
63 | ///
64 | /// The exception to submit as the bug report.
65 | public static void Report(Exception exception)
66 | {
67 | // Below never exits application by itself (by design) so execution of the application continues normally
68 | new BugReport().Report(exception, ExceptionThread.Main);
69 | }
70 | }
71 | }
--------------------------------------------------------------------------------
/NBug/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 |
8 |
9 | using System.Reflection;
10 | using System.Runtime.CompilerServices;
11 | using System.Runtime.InteropServices;
12 |
13 | // General Information about an assembly is controlled through the following
14 | // set of attributes. Change these attribute values to modify the information
15 | // associated with an assembly.
16 | [assembly: AssemblyTitle("NBug")]
17 | [assembly: AssemblyDescription("NBug bug reporting library created by Teoman Soygul.")]
18 | [assembly: AssemblyCulture("")]
19 |
20 | // Setting ComVisible to false makes the types in this assembly not visible
21 | // to COM components. If you need to access a type in this assembly from
22 | // COM, set the ComVisible attribute to true on that type.
23 | [assembly: ComVisible(false)]
24 |
25 | // The following GUID is for the ID of the typelib if this project is exposed to COM
26 | [assembly: Guid("6c55f06b-1a75-4e10-ad9a-168604ee2d91")]
27 |
28 | // Set up for unit testing
29 | [assembly:
30 | InternalsVisibleTo(
31 | "NBug.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100298c7bc6603288f349c24fe85cebfba2efbc6a88af29805efc852b93a86ba3c2e0a6b9979f49803b579387fcff27b2e97526b8001b3a68e0785da60352f9918a433cc4e7c3b143341289b10c0fd250d8aeddd5edecb049072d5a78c2eecb42fc5e3e5c32161cfc445bdc8dc366b0e52389cc50b07168b45d411c56e541b5bdae"
32 | )]
33 | [assembly:
34 | InternalsVisibleTo(
35 | "NBug.Configurator, PublicKey=0024000004800000940000000602000000240000525341310004000001000100298c7bc6603288f349c24fe85cebfba2efbc6a88af29805efc852b93a86ba3c2e0a6b9979f49803b579387fcff27b2e97526b8001b3a68e0785da60352f9918a433cc4e7c3b143341289b10c0fd250d8aeddd5edecb049072d5a78c2eecb42fc5e3e5c32161cfc445bdc8dc366b0e52389cc50b07168b45d411c56e541b5bdae"
36 | )]
37 |
38 | // Version information for an assembly consists of the following four values:
39 | // Major Version
40 | // Minor Version
41 | // Build Number
42 | // Revision
43 | // You can specify all the values or you can default the Build and Revision Numbers
44 | // by using the '*' as shown below:
45 | // [assembly: AssemblyVersion("1.0.*")]
--------------------------------------------------------------------------------
/NBug/Properties/Localization.de.Designer.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug/Properties/Localization.de.Designer.cs
--------------------------------------------------------------------------------
/NBug/Properties/Localization.es-MX.Designer.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug/Properties/Localization.es-MX.Designer.cs
--------------------------------------------------------------------------------
/NBug/Properties/Localization.fi-FI.Designer.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug/Properties/Localization.fi-FI.Designer.cs
--------------------------------------------------------------------------------
/NBug/Properties/Localization.hr.Designer.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug/Properties/Localization.hr.Designer.cs
--------------------------------------------------------------------------------
/NBug/Properties/Localization.ja.Designer.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug/Properties/Localization.ja.Designer.cs
--------------------------------------------------------------------------------
/NBug/Properties/Localization.ko-KR.Designer.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug/Properties/Localization.ko-KR.Designer.cs
--------------------------------------------------------------------------------
/NBug/Properties/Localization.nl.Designer.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug/Properties/Localization.nl.Designer.cs
--------------------------------------------------------------------------------
/NBug/Properties/Localization.pl-PL.Designer.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug/Properties/Localization.pl-PL.Designer.cs
--------------------------------------------------------------------------------
/NBug/Properties/Localization.pt-BR.Designer.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug/Properties/Localization.pt-BR.Designer.cs
--------------------------------------------------------------------------------
/NBug/Properties/Localization.ru-RU.Designer.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug/Properties/Localization.ru-RU.Designer.cs
--------------------------------------------------------------------------------
/NBug/Properties/SettingsOverride.cs:
--------------------------------------------------------------------------------
1 | // --------------------------------------------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
4 | //
5 | // --------------------------------------------------------------------------------------------------------------------
6 |
7 | namespace NBug.Properties
8 | {
9 | using System.IO;
10 | using System.Xml;
11 | using System.Xml.Linq;
12 |
13 | public static class SettingsOverride
14 | {
15 | ///
16 | /// Gets or sets a value indicating whether the library settings are to be overridden. If the settings are to be overridden by code
17 | /// or by some other library, it shall be done before any of the static members of the class is accessed.
18 | /// Note that setting this to true prevents default settings from getting loaded so should be used with caution.
19 | ///
20 | internal static bool Overridden { get; set; }
21 |
22 | ///
23 | /// Loads custom settings file from the designated stream. Before calling this, you must set SettingsOverride.Overridden = true;
24 | /// or the default settings will be loaded as the static constructor gets called otherwise.
25 | ///
26 | /// Stream to load the settings from.
27 | public static void LoadCustomSettings(Stream settingsFile)
28 | {
29 | Overridden = true;
30 |
31 | try
32 | {
33 | NBug.Settings.LoadCustomSettings(XElement.Load(settingsFile));
34 | }
35 | catch (XmlException)
36 | {
37 | // Root element is missing so recreate the configuration file
38 | NBug.Settings.LoadCustomSettings(XElement.Parse(""));
39 | }
40 | }
41 |
42 | ///
43 | /// Loads custom settings file from the designated file. Before calling this, you must set SettingsOverride.Overridden = true;
44 | /// or the default settings will be loaded as the static constructor gets called otherwise.
45 | ///
46 | /// File to load the settings from. Used within XElement.Load(path)
47 | public static void LoadCustomSettings(string settingsFilePath)
48 | {
49 | Overridden = true;
50 |
51 | try
52 | {
53 | NBug.Settings.LoadCustomSettings(XElement.Load(settingsFilePath));
54 | }
55 | catch (XmlException)
56 | {
57 | // Root element is missing so recreate the configuration file
58 | NBug.Settings.LoadCustomSettings(XElement.Parse(""));
59 | }
60 | }
61 |
62 | public static void SaveCustomSettings(Stream settingsFile, bool encryptConnectionStrings)
63 | {
64 | NBug.Settings.SaveCustomSettings(settingsFile, encryptConnectionStrings);
65 | }
66 |
67 | public static void SaveCustomSettings(Stream settingsFile)
68 | {
69 | NBug.Settings.SaveCustomSettings(settingsFile, false);
70 | }
71 | }
72 | }
--------------------------------------------------------------------------------
/NBug/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | Auto
17 |
18 |
19 | Auto
20 |
21 |
22 | 10
23 |
24 |
25 | 5
26 |
27 |
28 | 30
29 |
30 |
31 | CurrentDirectory
32 |
33 |
34 | Tiny
35 |
36 |
37 | False
38 |
39 |
40 | True
41 |
42 |
43 | False
44 |
45 |
46 | False
47 |
48 |
49 | True
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/NBug/resources/Error_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug/resources/Error_16.png
--------------------------------------------------------------------------------
/NBug/resources/Feedback.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug/resources/Feedback.png
--------------------------------------------------------------------------------
/NBug/resources/Forum_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug/resources/Forum_16.png
--------------------------------------------------------------------------------
/NBug/resources/Help_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug/resources/Help_16.png
--------------------------------------------------------------------------------
/NBug/resources/NBug_Icon_PNG_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug/resources/NBug_Icon_PNG_16.png
--------------------------------------------------------------------------------
/NBug/resources/NBug_icon_16.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug/resources/NBug_icon_16.ico
--------------------------------------------------------------------------------
/NBug/resources/NBug_icon_16_borders.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug/resources/NBug_icon_16_borders.ico
--------------------------------------------------------------------------------
/NBug/resources/Send.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug/resources/Send.png
--------------------------------------------------------------------------------
/NBug/resources/VS2010_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug/resources/VS2010_16.png
--------------------------------------------------------------------------------
/NBug/resources/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/NBug/resources/icon.ico
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # [](http://soygul.com/nbug/)
2 |
3 | [](https://travis-ci.org/soygul/NBug)
4 |
5 | NBug is a .NET library created to automate the bug reporting process. It automatically creates and sends:
6 |
7 | * Bug reports.
8 | * Crash reports with minidump.
9 | * Error/exception reports with stack trace + ext. info. It can also be set up as a user feedback system (i.e. feature requests).
10 |
11 | Error reports can be sent to:
12 |
13 | * E-mail addresses.
14 | * HTTP(POST)/FTP servers.
15 | * Azure Blob storage.
16 | * Redmine/Mantis bug trackers.
17 | * Any custom destination via implementing the [`IProtocolFactory`](NBug/Core/Submission/IProtocolFactory.cs) interface. See the source code for example implementations.
18 |
19 | It has been successfully used in many projects including [Git Extensions](https://github.com/gitextensions/gitextensions), as well as my own projects.
20 |
21 | ## Quickstart
22 | Read the quickstart here: http://soygul.com/nbug/
23 |
24 | In a typical scenario all you need is to add the NuGet package (or compile and use the `NBug.dll` directly, which is always more up-to-date) and add following to your application's `Program.cs` file (assuming it is a console app):
25 |
26 | ```csharp
27 | // Uncomment the following after testing to see that NBug is working as configured
28 | // NBug.Settings.ReleaseMode = true;
29 |
30 | // NBug config
31 | NBug.Settings.Destination1 = "Type=Mail;From=me@mycompany.com;To=bugtracker@mycompany.com;SmtpServer=smtp.mycompany.com;";
32 |
33 | // Attach exception handlers after all configuration is done
34 | AppDomain.CurrentDomain.UnhandledException += NBug.Handler.UnhandledException;
35 | ```
36 |
37 | After this, any unhandled exception will be formatted and sent to the configured e-mail address, after the app is restarted by the user.
38 |
39 | ## Questions
40 | You can post your question on StackOverflow with NBug tag: http://stackoverflow.com/questions/tagged/nbug
41 |
42 | ## Get it on [NuGet](https://www.nuget.org/packages/NBug/)
43 |
44 | ```powershell
45 | Install-Package NBug
46 | ```
47 |
48 | **Note**: NuGet versions tends to be outdated so it is better to compile the project yourself to get the latest changes.
49 |
50 | ## CodePlex Home
51 | Old (up to v1.1.1 release) project source is hosted at CodePlex, where you can find more information about the project: http://nbug.codeplex.com/
52 |
--------------------------------------------------------------------------------
/Settings.StyleCop:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NBug Project
6 | Copyright (c) 2011 - 2013 Teoman Soygul. Licensed under MIT license.
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Signing.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soygul/NBug/6489e3cf4d2105fbbab1b0c7114604a49dca7b50/Signing.snk
--------------------------------------------------------------------------------