Commit ebe1c906 authored by Brickner_cp's avatar Brickner_cp

Warnings, Code Analysis and Documentation. 5 warnings left.

PreEmptive Analysis.
parent a3b27233
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
</asmlist> </asmlist>
</input> </input>
<output> <output>
<file dir="${configdir}\Dotfuscated" /> <file dir="${configdir}\..\PcapDotNet\3rdParty\PcapDotNet.Analysis" />
</output> </output>
<renaming> <renaming>
<option>disable</option> <option>disable</option>
...@@ -24,11 +24,11 @@ ...@@ -24,11 +24,11 @@
</mapoutput> </mapoutput>
</mapping> </mapping>
<referencerulelist> <referencerulelist>
<referencerule rulekey="{229FD6F8-5BCC-427b-8F72-A7A413ECDF1A}" /> <referencerule rulekey="{7D9C8B02-2383-420f-8740-A9760394C2C1}" />
<referencerule rulekey="{6655B10A-FD58-462d-8D4F-5B1316DFF0FF}" /> <referencerule rulekey="{6655B10A-FD58-462d-8D4F-5B1316DFF0FF}" />
<referencerule rulekey="{2B7E7C8C-A39A-4db8-9DFC-6AFD38509061}" /> <referencerule rulekey="{2B7E7C8C-A39A-4db8-9DFC-6AFD38509061}" />
<referencerule rulekey="{89769974-93E9-4e71-8D92-BE70E855ACFC}" /> <referencerule rulekey="{89769974-93E9-4e71-8D92-BE70E855ACFC}" />
<referencerule rulekey="{7D9C8B02-2383-420f-8740-A9760394C2C1}" /> <referencerule rulekey="{229FD6F8-5BCC-427b-8F72-A7A413ECDF1A}" />
</referencerulelist> </referencerulelist>
</renaming> </renaming>
<sos mergeruntime="true"> <sos mergeruntime="true">
...@@ -40,20 +40,20 @@ ...@@ -40,20 +40,20 @@
<codetransformlist> <codetransformlist>
<codetransform name="analytics" /> <codetransform name="analytics" />
</codetransformlist> </codetransformlist>
<type name="PcapDotNet.Analysis.CodePlexAnalysis"> <type name="PcapDotNet.Analysis.PcapDotNetAnalysis">
<method name="Setup" signature="PcapDotNet.Analysis.CodePlexAnalysis()" /> <method name="Setup" signature="void()" />
</type> </type>
<propertylist> <propertylist>
<property name="OptInSourceName" value="OptIn" />
<property name="OptInSourceElement" value="Property" /> <property name="OptInSourceElement" value="Property" />
<property name="ExtendedKeySourceOwner" value="" /> <property name="ExtendedKeySourceOwner" value="" />
<property name="UseSSL" value="False" /> <property name="UseSSL" value="False" />
<property name="InstanceIdSourceOwner" value="" /> <property name="InstanceIdSourceOwner" value="" />
<property name="CustomEndpoint" value="so-s.info/PreEmptive.Web.Services.Messaging/MessagingServiceV2.asmx" /> <property name="CustomEndpoint" value="so-s.info/PreEmptive.Web.Services.Messaging/MessagingServiceV2.asmx" />
<property name="OptInSourceOwner" value="PcapDotNet.Analysis.PcapDotNetAnalysis" />
<property name="ExtendedKeySourceName" value="" /> <property name="ExtendedKeySourceName" value="" />
<property name="ExtendedKeySourceElement" value="None" /> <property name="ExtendedKeySourceElement" value="None" />
<property name="InstanceIdSourceName" value="" /> <property name="InstanceIdSourceName" value="" />
<property name="OptInSourceOwner" value="PcapDotNet.Analysis.CodePlexAnalysis" /> <property name="OptInSourceName" value="OptIn" />
<property name="InstanceIdSourceElement" value="None" /> <property name="InstanceIdSourceElement" value="None" />
</propertylist> </propertylist>
</extattribute> </extattribute>
...@@ -65,16 +65,16 @@ ...@@ -65,16 +65,16 @@
<method name="Setup" signature="PcapDotNet.Packets.Analysis()" /> <method name="Setup" signature="PcapDotNet.Packets.Analysis()" />
</type> </type>
<propertylist> <propertylist>
<property name="OptInSourceName" value="OptIn" />
<property name="OptInSourceElement" value="Property" /> <property name="OptInSourceElement" value="Property" />
<property name="ExtendedKeySourceOwner" value="" /> <property name="ExtendedKeySourceOwner" value="" />
<property name="UseSSL" value="False" /> <property name="UseSSL" value="False" />
<property name="InstanceIdSourceOwner" value="" /> <property name="InstanceIdSourceOwner" value="" />
<property name="CustomEndpoint" value="so-s.info/PreEmptive.Web.Services.Messaging/MessagingServiceV2.asmx" /> <property name="CustomEndpoint" value="so-s.info/PreEmptive.Web.Services.Messaging/MessagingServiceV2.asmx" />
<property name="OptInSourceOwner" value="PcapDotNet.Packets.Analysis" />
<property name="ExtendedKeySourceName" value="" /> <property name="ExtendedKeySourceName" value="" />
<property name="ExtendedKeySourceElement" value="None" /> <property name="ExtendedKeySourceElement" value="None" />
<property name="InstanceIdSourceName" value="" /> <property name="InstanceIdSourceName" value="" />
<property name="OptInSourceOwner" value="PcapDotNet.Packets.Analysis" /> <property name="OptInSourceName" value="OptIn" />
<property name="InstanceIdSourceElement" value="None" /> <property name="InstanceIdSourceElement" value="None" />
</propertylist> </propertylist>
</extattribute> </extattribute>
...@@ -82,20 +82,20 @@ ...@@ -82,20 +82,20 @@
<codetransformlist> <codetransformlist>
<codetransform name="analytics" /> <codetransform name="analytics" />
</codetransformlist> </codetransformlist>
<type name="PcapDotNet.Analysis.PcapDotNetAnalysis"> <type name="PcapDotNet.Analysis.CodePlexAnalysis">
<method name="Setup" signature="void()" /> <method name="Setup" signature="PcapDotNet.Analysis.CodePlexAnalysis()" />
</type> </type>
<propertylist> <propertylist>
<property name="OptInSourceName" value="OptIn" />
<property name="OptInSourceElement" value="Property" /> <property name="OptInSourceElement" value="Property" />
<property name="ExtendedKeySourceOwner" value="" /> <property name="ExtendedKeySourceOwner" value="" />
<property name="UseSSL" value="False" /> <property name="UseSSL" value="False" />
<property name="InstanceIdSourceOwner" value="" /> <property name="InstanceIdSourceOwner" value="" />
<property name="CustomEndpoint" value="so-s.info/PreEmptive.Web.Services.Messaging/MessagingServiceV2.asmx" /> <property name="CustomEndpoint" value="so-s.info/PreEmptive.Web.Services.Messaging/MessagingServiceV2.asmx" />
<property name="OptInSourceOwner" value="PcapDotNet.Analysis.CodePlexAnalysis" />
<property name="ExtendedKeySourceName" value="" /> <property name="ExtendedKeySourceName" value="" />
<property name="ExtendedKeySourceElement" value="None" /> <property name="ExtendedKeySourceElement" value="None" />
<property name="InstanceIdSourceName" value="" /> <property name="InstanceIdSourceName" value="" />
<property name="OptInSourceOwner" value="PcapDotNet.Analysis.PcapDotNetAnalysis" /> <property name="OptInSourceName" value="OptIn" />
<property name="InstanceIdSourceElement" value="None" /> <property name="InstanceIdSourceElement" value="None" />
</propertylist> </propertylist>
</extattribute> </extattribute>
......
<Configuration>
<CodeStyleSettings>
<ExternalPath IsNull="False">
</ExternalPath>
<Sharing>SOLUTION</Sharing>
<CSharp>
<FormatSettings>
<ANONYMOUS_METHOD_DECLARATION_BRACES>NEXT_LINE</ANONYMOUS_METHOD_DECLARATION_BRACES>
<CASE_BLOCK_BRACES>NEXT_LINE</CASE_BLOCK_BRACES>
<INITIALIZER_BRACES>NEXT_LINE</INITIALIZER_BRACES>
<MODIFIERS_ORDER IsNull="False">
<Item>public</Item>
<Item>protected</Item>
<Item>internal</Item>
<Item>private</Item>
<Item>new</Item>
<Item>abstract</Item>
<Item>virtual</Item>
<Item>override</Item>
<Item>sealed</Item>
<Item>static</Item>
<Item>readonly</Item>
<Item>extern</Item>
<Item>unsafe</Item>
<Item>volatile</Item>
</MODIFIERS_ORDER>
<SPACE_AFTER_TYPECAST_PARENTHESES>False</SPACE_AFTER_TYPECAST_PARENTHESES>
<SPACE_AROUND_MULTIPLICATIVE_OP>True</SPACE_AROUND_MULTIPLICATIVE_OP>
<WRAP_LIMIT>160</WRAP_LIMIT>
</FormatSettings>
<UsingsSettings />
<Naming2>
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="TypesAndNamespaces" />
<PredefinedRule Inspect="True" Prefix="I" Suffix="" Style="AaBb" ElementKind="Interfaces" />
<PredefinedRule Inspect="True" Prefix="T" Suffix="" Style="AaBb" ElementKind="TypeParameters" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="MethodPropertyEvent" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Locals" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="LocalConstants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Parameters" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PublicFields" />
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateInstanceFields" />
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateStaticFields" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Constants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateConstants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="StaticReadonly" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateStaticReadonly" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="EnumMember" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Other" />
</Naming2>
</CSharp>
<VB>
<FormatSettings />
<ImportsSettings />
<Naming2>
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
</Naming2>
</VB>
<Web>
<Naming2 />
</Web>
<Xaml>
<Naming2 />
</Xaml>
<XML>
<FormatSettings />
</XML>
<GenerateMemberBody />
<Naming2>
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Parameters" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="TypesAndNamespaces" />
<PredefinedRule Inspect="True" Prefix="I" Suffix="" Style="AaBb" ElementKind="Interfaces" />
<PredefinedRule Inspect="True" Prefix="T" Suffix="" Style="AaBb" ElementKind="TypeParameters" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="MethodPropertyEvent" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Locals" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="LocalConstants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PublicFields" />
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateInstanceFields" />
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateStaticFields" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Constants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateConstants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="StaticReadonly" />
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateStaticReadonly" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="EnumMember" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Other" />
</Naming2>
</CodeStyleSettings>
</Configuration>
\ No newline at end of file
...@@ -3,6 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 11.00 ...@@ -3,6 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010 # Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PcapDotNet.Analysis", "PcapDotNet.Analysis\PcapDotNet.Analysis.csproj", "{AB555DA6-785B-4270-9CF8-4DD9A216280B}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PcapDotNet.Analysis", "PcapDotNet.Analysis\PcapDotNet.Analysis.csproj", "{AB555DA6-785B-4270-9CF8-4DD9A216280B}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AC18EC16-4912-41E2-867D-6C477271F78D}"
ProjectSection(SolutionItems) = preProject
PcapDotNet.Analysis.5.0.ReSharper = PcapDotNet.Analysis.5.0.ReSharper
..\..\PcapDotNet\src\PcapDotNet.CodeAnalysisDictionary.xml = ..\..\PcapDotNet\src\PcapDotNet.CodeAnalysisDictionary.xml
EndProjectSection
EndProject
Global Global
GlobalSection(TeamFoundationVersionControl) = preSolution GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 2 SccNumberOfProjects = 2
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>..\..\bin\Debug\PcapDotNet.Analysis.XML</DocumentationFile> <DocumentationFile>..\..\bin\Debug\PcapDotNet.Analysis.XML</DocumentationFile>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRuleSet>..\..\..\PcapDotNet\src\PcapDotNet.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
...@@ -35,12 +37,14 @@ ...@@ -35,12 +37,14 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>..\..\bin\Release\PcapDotNet.Analysis.XML</DocumentationFile> <DocumentationFile>..\..\bin\Release\PcapDotNet.Analysis.XML</DocumentationFile>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRuleSet>..\..\..\PcapDotNet\src\PcapDotNet.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SignAssembly>true</SignAssembly> <SignAssembly>true</SignAssembly>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<DelaySign>true</DelaySign> <DelaySign>false</DelaySign>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<AssemblyOriginatorKeyFile>..\..\..\PcapDotNet\src\PcapDotNet.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\..\..\PcapDotNet\src\PcapDotNet.snk</AssemblyOriginatorKeyFile>
...@@ -66,7 +70,15 @@ ...@@ -66,7 +70,15 @@
<Link>PcapDotNet.snk</Link> <Link>PcapDotNet.snk</Link>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<CodeAnalysisDictionary Include="..\..\..\PcapDotNet\src\PcapDotNet.CodeAnalysisDictionary.xml">
<Link>PcapDotNet.CodeAnalysisDictionary.xml</Link>
</CodeAnalysisDictionary>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>if not exist "$(SolutionDir)..\..\PcapDotNet\src\PcapDotNet.snk" ("%25PROGRAMFILES%25\Microsoft SDKs\Windows\v6.0A\bin\sn.exe" -k "$(SolutionDir)..\..\PcapDotNet\src\PcapDotNet.snk")</PreBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">
......
...@@ -5,8 +5,14 @@ using System.Text; ...@@ -5,8 +5,14 @@ using System.Text;
namespace PcapDotNet.Analysis namespace PcapDotNet.Analysis
{ {
/// <summary>
/// Used to send PreEmptive Runtime Intelligence Data.
/// </summary>
public static class PcapDotNetAnalysis public static class PcapDotNetAnalysis
{ {
/// <summary>
/// Initializes the Runtime Intelligence and make sures it will be closed on ProcessExit.
/// </summary>
public static void Initialize() public static void Initialize()
{ {
if (!_setup) if (!_setup)
...@@ -17,22 +23,36 @@ namespace PcapDotNet.Analysis ...@@ -17,22 +23,36 @@ namespace PcapDotNet.Analysis
} }
} }
/// <summary>
/// Counts a packet sent event.
/// </summary>
[PreEmptive.Attributes.Feature("Sent Packet")] [PreEmptive.Attributes.Feature("Sent Packet")]
public static void PacketSent() public static void PacketSent()
{ {
} }
/// <summary>
/// Counts a packet sent events according to the given <paramref name="count"/>.
/// </summary>
/// <param name="count">The number of packet sent event to count.</param>
public static void PacketSent(int count) public static void PacketSent(int count)
{ {
for (int i = 0; i != count; ++i) for (int i = 0; i != count; ++i)
PacketSent(); PacketSent();
} }
/// <summary>
/// Counts a packet received event.
/// </summary>
[PreEmptive.Attributes.Feature("Received Packet")] [PreEmptive.Attributes.Feature("Received Packet")]
public static void PacketReceived() public static void PacketReceived()
{ {
} }
/// <summary>
/// Counts a packet received events according to the given <paramref name="count"/>.
/// </summary>
/// <param name="count">The number of packet sent event to count.</param>
public static void PacketReceived(int count) public static void PacketReceived(int count)
{ {
for (int i = 0; i != count; ++i) for (int i = 0; i != count; ++i)
...@@ -49,6 +69,9 @@ namespace PcapDotNet.Analysis ...@@ -49,6 +69,9 @@ namespace PcapDotNet.Analysis
{ {
} }
/// <summary>
/// Choose whether to send PreEmptive Runtime Intelligence Data or not.
/// </summary>
public static bool OptIn { get; set; } public static bool OptIn { get; set; }
private static bool _setup; private static bool _setup;
......
using System.Reflection; using System;
using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
...@@ -35,5 +36,7 @@ using System.Runtime.InteropServices; ...@@ -35,5 +36,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: CLSCompliant(false)]
[assembly: PreEmptive.Attributes.Business("3E35F098-CE43-4F82-9E9D-05C8B1046A45")] // CodePlex [assembly: PreEmptive.Attributes.Business("3E35F098-CE43-4F82-9E9D-05C8B1046A45")] // CodePlex
[assembly: PreEmptive.Attributes.Application("A5F32868-8932-4CEC-B263-7D2CB74C3136")] // Pcap.Net [assembly: PreEmptive.Attributes.Application("A5F32868-8932-4CEC-B263-7D2CB74C3136")] // Pcap.Net
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
<Word>proteon</Word> <Word>proteon</Word>
<Word>qnx</Word> <!-- www.qnx.com --> <Word>qnx</Word> <!-- www.qnx.com -->
<Word>rcc</Word> <Word>rcc</Word>
<Word>rpcap</Word>
<Word>satnet</Word> <Word>satnet</Word>
<Word>sitara</Word> <Word>sitara</Word>
<Word>sna</Word> <Word>sna</Word>
......
using System; using System;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Management; using System.Management;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
...@@ -23,12 +24,17 @@ namespace PcapDotNet.Core.Extensions ...@@ -23,12 +24,17 @@ namespace PcapDotNet.Core.Extensions
/// <param name="livePacketDevice">The <see cref="LivePacketDevice"/> instance.</param> /// <param name="livePacketDevice">The <see cref="LivePacketDevice"/> instance.</param>
/// <returns>The GUID (NetCfgInstanceId) of the <see cref="LivePacketDevice"/> instance.</returns> /// <returns>The GUID (NetCfgInstanceId) of the <see cref="LivePacketDevice"/> instance.</returns>
/// <exception cref="InvalidOperationException">When the <see cref="LivePacketDevice.Name"/> doesn't match the expectations.</exception> /// <exception cref="InvalidOperationException">When the <see cref="LivePacketDevice.Name"/> doesn't match the expectations.</exception>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
public static string GetGuid(this LivePacketDevice livePacketDevice) public static string GetGuid(this LivePacketDevice livePacketDevice)
{ {
if (livePacketDevice == null)
throw new ArgumentNullException("livePacketDevice");
string livePacketDeviceName = livePacketDevice.Name; string livePacketDeviceName = livePacketDevice.Name;
if (!livePacketDeviceName.StartsWith(NamePrefix)) if (!livePacketDeviceName.StartsWith(NamePrefix, StringComparison.Ordinal))
{ {
throw new InvalidOperationException(string.Format("Invalid LivePacketDevice.Name format: {0} (should start with: {1})", throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
"Invalid Device Name format: {0} (should start with: {1})",
livePacketDevice.Name, NamePrefix)); livePacketDevice.Name, NamePrefix));
} }
...@@ -50,7 +56,7 @@ namespace PcapDotNet.Core.Extensions ...@@ -50,7 +56,7 @@ namespace PcapDotNet.Core.Extensions
{ {
string pnpDeviceId = key.GetValue("PnpInstanceID") as string; string pnpDeviceId = key.GetValue("PnpInstanceID") as string;
if (pnpDeviceId == null) if (pnpDeviceId == null)
throw new InvalidOperationException("Could not find PNPDeviceID in the registry"); throw new InvalidOperationException("Could not find PNP Device ID in the registry");
return pnpDeviceId; return pnpDeviceId;
} }
} }
...@@ -112,12 +118,12 @@ namespace PcapDotNet.Core.Extensions ...@@ -112,12 +118,12 @@ namespace PcapDotNet.Core.Extensions
{ {
string macAddress = managementObject["MACAddress"] as string; string macAddress = managementObject["MACAddress"] as string;
if (string.IsNullOrEmpty(macAddress)) if (string.IsNullOrEmpty(macAddress))
throw new InvalidOperationException("No MACAddress for WMI instance Win32_NetworkAdapter.PNPDeviceID: " + pnpDeviceId); throw new InvalidOperationException("No MAC Address for WMI instance with PNP Device ID: " + pnpDeviceId);
return new MacAddress(macAddress); return new MacAddress(macAddress);
} }
throw new InvalidOperationException("No MACAddress for WMI instance Win32_NetworkAdapter.PNPDeviceID: " + pnpDeviceId); throw new InvalidOperationException("No MAC Address for WMI instance with PNP Device ID: " + pnpDeviceId);
} }
} }
} }
\ No newline at end of file
// This file is used by Code Analysis to maintain
// CA_GLOBAL_SUPPRESS_MESSAGE macros that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
//
// To add a suppression to this file, right-click the message in the
// Error List, point to "Suppress Message(s)", and click
// "In Project Suppression File".
// You do not need to add suppressions to this file manually.
// https://connect.microsoft.com/VisualStudio/feedback/details/559820/getting-ca1806-on-c-cli-code-when-catching-exceptions
CA_GLOBAL_SUPPRESS_MESSAGE("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId="<Module>.__CxxRegisterExceptionObject(System.Void*,System.Void*)", Scope="member", Target="PcapDotNet.Core.BerkeleyPacketFilter.#Initialize(pcap*,System.String,PcapDotNet.Core.IpV4SocketAddress)");
// https://connect.microsoft.com/VisualStudio/feedback/details/551348/brocken-vs-2008-functionality-it-is-impossible-to-build-strong-name-c-cli-assembly
CA_GLOBAL_SUPPRESS_MESSAGE("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames");
...@@ -23,7 +23,7 @@ ReadOnlyCollection<LivePacketDevice^>^ LivePacketDevice::AllLocalMachine::get() ...@@ -23,7 +23,7 @@ ReadOnlyCollection<LivePacketDevice^>^ LivePacketDevice::AllLocalMachine::get()
&alldevs, errorBuffer) == -1) &alldevs, errorBuffer) == -1)
{ {
String^ errorString = gcnew String(errorBuffer); String^ errorString = gcnew String(errorBuffer);
throw gcnew InvalidOperationException(String::Format(CultureInfo::InvariantCulture, "Failed getting devices. WinPcap Error: {0}", errorString)); throw gcnew InvalidOperationException(String::Format(CultureInfo::InvariantCulture, "Failed getting devices. Error: {0}", errorString));
} }
try try
......
...@@ -27,7 +27,7 @@ void PacketCommunicator::DataLink::set(PcapDataLink value) ...@@ -27,7 +27,7 @@ void PacketCommunicator::DataLink::set(PcapDataLink value)
ReadOnlyCollection<PcapDataLink>^ PacketCommunicator::SupportedDataLinks::get() ReadOnlyCollection<PcapDataLink>^ PacketCommunicator::SupportedDataLinks::get()
{ {
throw gcnew NotSupportedException("Unsupported property to avoid WinPcap memory leak"); throw gcnew NotSupportedException("Unsupported property to avoid memory leak");
// pcap_free_datalinks(NULL); // pcap_free_datalinks(NULL);
/* /*
int* dataLinks; int* dataLinks;
...@@ -304,7 +304,7 @@ PacketCommunicator::PacketCommunicator(const char* source, int snapshotLength, P ...@@ -304,7 +304,7 @@ PacketCommunicator::PacketCommunicator(const char* source, int snapshotLength, P
errorBuffer); // error buffer errorBuffer); // error buffer
if (pcapDescriptor == NULL) if (pcapDescriptor == NULL)
throw gcnew InvalidOperationException(String::Format(CultureInfo::InvariantCulture, "Unable to open the adapter. Adapter name: {0}. WinPcap Error: {1}", gcnew String(source), gcnew String(errorBuffer))); throw gcnew InvalidOperationException(String::Format(CultureInfo::InvariantCulture, "Unable to open the adapter. Adapter name: {0}. Error: {1}", gcnew String(source), gcnew String(errorBuffer)));
_pcapDescriptor = pcapDescriptor; _pcapDescriptor = pcapDescriptor;
_ipV4Netmask = dynamic_cast<IpV4SocketAddress^>(netmask); _ipV4Netmask = dynamic_cast<IpV4SocketAddress^>(netmask);
......
...@@ -22,7 +22,14 @@ namespace PcapDotNet { namespace Core ...@@ -22,7 +22,14 @@ namespace PcapDotNet { namespace Core
/// </summary> /// </summary>
public ref class PacketCommunicator abstract : System::IDisposable public ref class PacketCommunicator abstract : System::IDisposable
{ {
public: private:
static PacketCommunicator()
{
PcapDotNet::Analysis::PcapDotNetAnalysis::Initialize();
}
public:
/// <summary> /// <summary>
/// The link layer of an adapter. /// The link layer of an adapter.
/// </summary> /// </summary>
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<CodeAnalysisDictionary Include="..\PcapDotNet.CodeAnalysisDictionary.xml" /> <CodeAnalysisDictionary Include="..\PcapDotNet.CodeAnalysisDictionary.xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="PcapDotNet.Analysis, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4b6f3e583145a652"> <Reference Include="PcapDotNet.Analysis, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce74aebf1caba0fa">
<HintPath>..\..\3rdParty\PcapDotNet.Analysis\PcapDotNet.Analysis.dll</HintPath> <HintPath>..\..\3rdParty\PcapDotNet.Analysis\PcapDotNet.Analysis.dll</HintPath>
</Reference> </Reference>
<Reference Include="System"> <Reference Include="System">
...@@ -47,6 +47,16 @@ ...@@ -47,6 +47,16 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="GlobalSuppressions.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Properties\AssemblyInfo.cpp" /> <ClCompile Include="Properties\AssemblyInfo.cpp" />
<ClCompile Include="DeviceAddress.cpp" /> <ClCompile Include="DeviceAddress.cpp" />
<ClCompile Include="IpV4SocketAddress.cpp" /> <ClCompile Include="IpV4SocketAddress.cpp" />
......
...@@ -80,6 +80,7 @@ ...@@ -80,6 +80,7 @@
<ClCompile Include="PcapDataLink.cpp" /> <ClCompile Include="PcapDataLink.cpp" />
<ClCompile Include="PcapError.cpp" /> <ClCompile Include="PcapError.cpp" />
<ClCompile Include="PcapLibrary.cpp" /> <ClCompile Include="PcapLibrary.cpp" />
<ClCompile Include="GlobalSuppressions.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="DeviceAddress.h"> <ClInclude Include="DeviceAddress.h">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment