Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Port to .NET Standard #84

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions JabberNet.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.26228.9
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".paket", ".paket", "{BFD2D70D-3C18-4BFD-B70E-38ED872B8F67}"
ProjectSection(SolutionItems) = preProject
Expand Down
104 changes: 16 additions & 88 deletions src/JabberNet.Netlib.Dns/JabberNet.Netlib.Dns.csproj
Original file line number Diff line number Diff line change
@@ -1,93 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{40AC7A7C-D3E5-46DF-B740-06BD9D2A00E1}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>JabberNet.Netlib.Dns</RootNamespace>
<AssemblyName>JabberNet.Netlib.Dns</AssemblyName>
<SignAssembly>false</SignAssembly>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
<UpgradeBackupLocation />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
<TargetFramework>netstandard1.3</TargetFramework>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<FileVersion>3.0.0.0</FileVersion>
<Version>3.0.0-preview1</Version>
<Company>The ASP Emporium (http://www.aspemporium.com/); Jabber-Net contributors</Company>
<Authors>ForNeVeR</Authors>
<Product>Jabber-Net</Product>
<Description>Allows for a complete DNS record lookup on a given domain using the Windows API.</Description>
<Copyright>The ASP Emporium (http://www.aspemporium.com/); Copyright (c) Jabber-Net Contributors, 2008—2017</Copyright>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\JabberNet.Netlib.Dns.xml</DocumentationFile>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>bin\Release\JabberNet.Netlib.Dns.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="dns.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<PackageReference Include="System.Collections" Version="4.3.0" />
<PackageReference Include="System.Linq" Version="4.3.0" />
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- 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.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->

</Project>
11 changes: 0 additions & 11 deletions src/JabberNet.Netlib.Dns/Properties/AssemblyInfo.cs

This file was deleted.

143 changes: 17 additions & 126 deletions src/JabberNet.Netlib.Dns/dns.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Collections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using JabberNet.Netlib.Dns.Records;

namespace JabberNet.Netlib.Dns
Expand Down Expand Up @@ -343,8 +343,7 @@ enum DnsFreeType: uint
/// InnerException property.
/// </para>
/// </remarks>
[Serializable]
public class DnsException: ApplicationException, ISerializable
public class DnsException: Exception
{
private readonly uint errcode = (uint) DnsQueryReturnCode.SUCCESS;

Expand Down Expand Up @@ -460,25 +459,6 @@ public uint ErrorCode
public DnsException(string message, Exception innerException): base(message, innerException)
{
}

void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("errcode", errcode);
base.GetObjectData(info, context);
}

/// <summary>
/// Initializes a new instance of <see cref="DnsException"/> for <see cref="ISerializable"/>
/// </summary>
/// <param name="info">the serialization information</param>
/// <param name="context">the context</param>
/// <remarks>
/// Used by the <see cref="ISerializable"/> interface.
/// </remarks>
public DnsException(SerializationInfo info, StreamingContext context): base(info, context)
{
errcode = info.GetUInt32("errcode");
}
}

/// <summary>
Expand Down Expand Up @@ -729,93 +709,6 @@ public int CompareTo(object obj)
#endregion
}

/// <summary>
/// Represents a collection of <see cref="DnsWrapper"/> objects.
/// </summary>
/// <remarks>
/// The DnsWrapperCollection is a collection of <see cref="DnsWrapper"/>
/// objects. The resultant collection represents all of the DNS records
/// for the given domain that was looked up. This class cannot be directly
/// created - it is created by the <see cref="DnsRequest"/> and
/// <see cref="DnsResponse"/> classes to hold the returned DNS
/// records for the given domain.
/// </remarks>
public class DnsWrapperCollection: ReadOnlyCollectionBase, IEnumerable
{
internal DnsWrapperCollection()
{
}

internal bool Contains(DnsWrapper w)
{
foreach(DnsWrapper wrapper in InnerList)
if (w.Equals(wrapper))
return true;

return false;
}

internal void Add(DnsWrapper w)
{
InnerList.Add(w);
}

/// <summary>
/// Gets the <see cref="DnsWrapper"/> at the specified
/// ordinal in the collection
/// </summary>
/// <remarks>
/// Gets the <see cref="DnsWrapper"/> at the specified
/// index of the collection.
/// </remarks>
/// <param name="i">The index to retrieve from the collection.</param>
/// <value>The <see cref="DnsWrapper"/> at the specified index of
/// the collection.</value>
public DnsWrapper this[int i]
{
get
{
return (DnsWrapper) InnerList[i];
}
}

IEnumerator IEnumerable.GetEnumerator()
{
return new DnsWrapperCollectionEnumerator(this);
}

class DnsWrapperCollectionEnumerator: IEnumerator
{
private int idx = -1;
private readonly DnsWrapperCollection coll;

public DnsWrapperCollectionEnumerator(DnsWrapperCollection coll)
{
this.coll = coll;
}

void IEnumerator.Reset()
{
idx=-1;
}

bool IEnumerator.MoveNext()
{
idx++;

return idx < coll.Count;
}

object IEnumerator.Current
{
get
{
return coll[idx];
}
}
}
}

/// <summary>
/// Represents one DNS request. Allows for a complete DNS record lookup
/// on a given _Domain using the Windows API.
Expand Down Expand Up @@ -1453,8 +1346,6 @@ private void Initialize(string domain)
/// </remarks>
public DnsResponse GetResponse(DnsRecordType dnstype)
{
if (Environment.OSVersion.Platform != PlatformID.Win32NT)
throw new NotSupportedException("This API is found only on Windows NT or better.");

if (_domain == null)
throw new ArgumentNullException();
Expand Down Expand Up @@ -1567,11 +1458,11 @@ private static void GetData(IntPtr ptr, ref DnsRecord dnsrec, ref object Data)
/// </remarks>
public class DnsResponse
{
private readonly DnsWrapperCollection rawrecords;
private readonly List<DnsWrapper> rawrecords;

internal DnsResponse()
{
rawrecords = new DnsWrapperCollection();
rawrecords = new List<DnsWrapper>();
}

/// <summary>
Expand All @@ -1585,7 +1476,7 @@ internal DnsResponse()
/// is wrapped by the <see cref="GetRecords"/> method.
/// </remarks>
/// <value>Gets a collection of <see cref="DnsWrapper"/> objects.</value>
public DnsWrapperCollection RawRecords
public List<DnsWrapper> RawRecords
{
get
{
Expand All @@ -1603,8 +1494,8 @@ public DnsWrapperCollection RawRecords
/// value indicating the type of DNS record to get from the list of
/// all DNS records (available in the <see cref="RawRecords"/>
/// property.</param>
/// <returns>an <see cref="ArrayList"/> of one of the types
/// specified in the <see cref="netlib.Dns.Records"/> namespace based
/// <returns>a <see cref="List{T}"/> of one of the types
/// specified in the <see cref="Records"/> namespace based
/// on the <see cref="DnsRecordType"/> argument representing the
/// type of DNS record desired.
/// </returns>
Expand Down Expand Up @@ -1651,9 +1542,9 @@ public DnsWrapperCollection RawRecords
/// </item>
/// </list>
/// </remarks>
public ArrayList GetRecords(DnsRecordType type)
public List<object> GetRecords(DnsRecordType type)
{
ArrayList arr = new ArrayList();
List<object> arr = new List<object>();
foreach(DnsWrapper dnsentry in rawrecords)
if (dnsentry.Equals(type))
arr.Add(dnsentry.RecordData);
Expand All @@ -1674,8 +1565,8 @@ public SRVRecord[] SRVRecords
{
get
{
ArrayList arr = GetRecords(DnsRecordType.SRV);
return (SRVRecord[])arr.ToArray(typeof(SRVRecord));
List<object> arr = GetRecords(DnsRecordType.SRV);
return arr.Cast<SRVRecord>().ToArray();
}
}

Expand All @@ -1692,8 +1583,8 @@ public TXTRecord[] TXTRecords
{
get
{
ArrayList arr = GetRecords(DnsRecordType.TEXT);
return (TXTRecord[])arr.ToArray(typeof(TXTRecord));
List<object> arr = GetRecords(DnsRecordType.TEXT);
return arr.Cast<TXTRecord>().ToArray();
}
}
/// <summary>
Expand All @@ -1709,8 +1600,8 @@ public MXRecord[] MXRecords
{
get
{
ArrayList arr = GetRecords(DnsRecordType.MX);
return (MXRecord[]) arr.ToArray(typeof(MXRecord));
List<object> arr = GetRecords(DnsRecordType.MX);
return arr.Cast<MXRecord>().ToArray();
}
}
}
Expand Down
9 changes: 0 additions & 9 deletions src/JabberNet/AssemblyInfo.cs

This file was deleted.

Loading