From 944b9125252a01bf9bd52f6f4521618b96a297ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Ulsberg?= Date: Wed, 12 Nov 2014 10:15:28 +0100 Subject: [PATCH] Removed SentryModule in place of an IDictionary as per @xpicio's suggestion in #55. --- src/app/SharpRaven/Data/JsonPacket.cs | 4 +- src/app/SharpRaven/Data/SentryModule.cs | 54 ---------------------- src/app/SharpRaven/SharpRaven.csproj | 1 - src/app/SharpRaven/Utilities/SystemUtil.cs | 23 +++++---- 4 files changed, 16 insertions(+), 66 deletions(-) delete mode 100644 src/app/SharpRaven/Data/SentryModule.cs diff --git a/src/app/SharpRaven/Data/JsonPacket.cs b/src/app/SharpRaven/Data/JsonPacket.cs index d8ee9d1d..b497bec8 100644 --- a/src/app/SharpRaven/Data/JsonPacket.cs +++ b/src/app/SharpRaven/Data/JsonPacket.cs @@ -106,9 +106,7 @@ public JsonPacket(string project) private JsonPacket() { // Get assemblies. - Modules = SystemUtil - .GetModules() - .ToDictionary(k => k.Name, v => v.Version); + Modules = SystemUtil.GetModules(); // The current hostname ServerName = Environment.MachineName; diff --git a/src/app/SharpRaven/Data/SentryModule.cs b/src/app/SharpRaven/Data/SentryModule.cs deleted file mode 100644 index 10d23356..00000000 --- a/src/app/SharpRaven/Data/SentryModule.cs +++ /dev/null @@ -1,54 +0,0 @@ -#region License - -// Copyright (c) 2014 The Sentry Team and individual contributors. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are permitted -// provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list of -// conditions and the following disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. Neither the name of the Sentry nor the names of its contributors may be used to -// endorse or promote products derived from this software without specific prior written -// permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#endregion - -namespace SharpRaven.Data -{ - /// - /// A module or library that might be in use and thus could relevant for debugging purposes. - /// - public class SentryModule - { - /// - /// Gets or sets the name of the module (or library). - /// - /// - /// The name of the module (or library). - /// - public string Name { get; set; } - - /// - /// Gets or sets the version of the module (or library). - /// - /// - /// The version of the module (or library). - /// - public string Version { get; set; } - } -} \ No newline at end of file diff --git a/src/app/SharpRaven/SharpRaven.csproj b/src/app/SharpRaven/SharpRaven.csproj index c63214c1..837bf421 100644 --- a/src/app/SharpRaven/SharpRaven.csproj +++ b/src/app/SharpRaven/SharpRaven.csproj @@ -79,7 +79,6 @@ - diff --git a/src/app/SharpRaven/Utilities/SystemUtil.cs b/src/app/SharpRaven/Utilities/SystemUtil.cs index 3a7a2bd4..98b622f1 100644 --- a/src/app/SharpRaven/Utilities/SystemUtil.cs +++ b/src/app/SharpRaven/Utilities/SystemUtil.cs @@ -32,8 +32,6 @@ using System.Collections.Generic; using System.Linq; -using SharpRaven.Data; - namespace SharpRaven.Utilities { /// @@ -47,15 +45,24 @@ public static class SystemUtil /// /// All loaded modules. /// - public static IEnumerable GetModules() + public static IDictionary GetModules() { - var assemblies = AppDomain.CurrentDomain.GetAssemblies(); + var assemblies = AppDomain.CurrentDomain + .GetAssemblies() + .Select(a => a.GetName()) + .OrderBy(a => a.Name); + + var dictionary = new Dictionary(); - return assemblies.Select(a => a.GetName()).OrderBy(a => a.Name).Select(a => new SentryModule + foreach (var assembly in assemblies) { - Name = a.Name, - Version = a.Version.ToString() - }); + if (dictionary.ContainsKey(assembly.Name)) + continue; + + dictionary.Add(assembly.Name, assembly.Version.ToString()); + } + + return dictionary; } } } \ No newline at end of file