Skip to content

Commit

Permalink
Adding netstandard2.0 target
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaCo committed May 28, 2018
1 parent a1f79ba commit eb901f6
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 78 deletions.
20 changes: 13 additions & 7 deletions samples/MiniDig/MiniDig.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<TargetFrameworks>netcoreapp1.1;netcoreapp2.0</TargetFrameworks>
<AssemblyName>MiniDig</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>MiniDig</PackageId>
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -21,19 +20,26 @@

<ItemGroup>
<PackageReference Include="Serilog.Sinks.File" Version="3.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.CommandLineUtils" Version="1.1.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="1.4.0" />
<PackageReference Include="Microsoft.Extensions.CommandLineUtils" Version="1.1.1" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">
<DefineConstants>$(DefineConstants);PORTABLE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
<DefineConstants>$(DefineConstants);PORTABLE</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">
<PackageReference Include="System.Threading.Thread" Version="4.3.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.1" />
</ItemGroup>

</Project>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.2" />
</ItemGroup>
</Project>
6 changes: 2 additions & 4 deletions samples/MiniDig/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ public class Program
{
public static void Main(string[] args)
{
var loggerFactory = new LoggerFactory().WithFilter(new FilterLoggerSettings()
{
{ "Default", LogLevel.Warning }
});
var loggerFactory = new LoggerFactory();
//loggerFactory.AddConsole();

var logFilename = $"Log/dig.log";
Expand All @@ -30,6 +27,7 @@ public static void Main(string[] args)

loggerFactory.AddSerilog(new LoggerConfiguration()
.Enrich.FromLogContext()
.Filter.ByExcluding(e => e.Level < Serilog.Events.LogEventLevel.Information)
.WriteTo.File(logFilename, shared: true)
.CreateLogger());

Expand Down
20 changes: 10 additions & 10 deletions src/DnsClient/DnsClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@
<VersionPrefix>1.0.8</VersionPrefix>
<VersionSuffix Condition="'$(VersionSuffix)'!='' AND '$(BuildNumber)' != ''">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>

<TargetFrameworks>netstandard1.3;net45</TargetFrameworks>
<TargetFrameworks>netstandard1.3;netstandard2.0;net45</TargetFrameworks>

<Product>DnsClient.NET</Product>
<Description>DnsClient.NET is a simple yet very powerful and high performant open source library for the .NET Framework to do DNS lookups</Description>

<Copyright>Copyright (c) 2017 MichaConrad</Copyright>
<Authors>MichaCo</Authors>
<Authors>MichaCo</Authors>
<AssemblyName>DnsClient</AssemblyName>

<AssemblyOriginatorKeyFile>../../tools/key.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>

<PackageId>DnsClient</PackageId>
<PackageTags>DNS;Name Server;CSharp;.NET;.NET Core</PackageTags>

<PackageIconUrl>http://dnsclient.michaco.net/favicon-196x196.png</PackageIconUrl>
<PackageProjectUrl>http://dnsclient.michaco.net</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/MichaCo/DnsClient.NET/blob/master/LICENSE</PackageLicenseUrl>
<WebPage>http://dnsclient.michaco.net</WebPage>

<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/MichaCo/DnsClient.NET</RepositoryUrl>

<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Buffers" Version="4.3.0" />
<PackageReference Include="System.Buffers" Version="4.4.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
Expand All @@ -55,8 +55,8 @@
<DefineConstants>$(DefineConstants);PORTABLE</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard1.3|AnyCPU'">

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);PORTABLE</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
Expand Down
10 changes: 4 additions & 6 deletions test/Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<PropertyGroup>
<TargetFrameworks>netcoreapp1.1;net46</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<AssemblyName>Benchmarks</AssemblyName>
<OutputType>Exe</OutputType>
<AssemblyOriginatorKeyFile>../../tools/key.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>

<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netcoreapp1.1|AnyCPU'">
Expand All @@ -23,7 +23,5 @@

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.10.5" />
<PackageReference Include="System.Buffers" Version="4.3.0" />
</ItemGroup>

</Project>
</Project>
13 changes: 6 additions & 7 deletions test/DnsClient.Tests/DatagramReaderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void DatagramReader_LabelTest_DnsName()

reader.Index = 36;
DnsString name = reader.ReadDnsName();
Assert.Equal(name.Value, "aa.com.");
Assert.Equal("aa.com.", name.Value);
}

[Fact]
Expand All @@ -58,10 +58,9 @@ public void DatagramReader_LabelTest_DnsName2()

reader.Index = 36;
DnsString name = reader.ReadDnsName();
Assert.Equal(name.Value, "eeeee.dd.c.aa.com.");
Assert.Equal("eeeee.dd.c.aa.com.", name.Value);
}


[Fact]
public void DatagramReader_DnsName_FromBytesValid()
{
Expand Down Expand Up @@ -128,8 +127,8 @@ public void DatagramReader_ReadUInt()

var result = reader.ReadUInt16();

Assert.Equal(result, 1);
Assert.Equal(reader.Index, 2);
Assert.Equal(1, result);
Assert.Equal(2, reader.Index);
}

[Fact]
Expand All @@ -139,8 +138,8 @@ public void DatagramReader_ReadUIntReverse()

var result = reader.ReadUInt16NetworkOrder();

Assert.Equal(result, 1);
Assert.Equal(reader.Index, 2);
Assert.Equal(1, result);
Assert.Equal(2, reader.Index);
}

[Fact]
Expand Down
34 changes: 16 additions & 18 deletions test/DnsClient.Tests/DnsClient.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp1.1;net46</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<AssemblyName>DnsClient.Tests</AssemblyName>
<AssemblyOriginatorKeyFile>../../tools/key.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand All @@ -25,31 +25,29 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Moq" Version="4.7.9" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="Moq" Version="4.8.2" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">
<PackageReference Include="Microsoft.CodeCoverage" Version="1.0.3" />
<PackageReference Include="System.Diagnostics.Tools" Version="4.3.0" />
<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.2" />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants>$(DefineConstants);ENABLE_REMOTE_DNS</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>

</Project>
</Project>
10 changes: 5 additions & 5 deletions test/DnsClient.Tests/DnsMessageHandlerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public void DnsRecordFactory_ResolveARecord()
var handle = new DnsUdpMessageHandler(true);
var result = handle.GetResponseMessage(new System.ArraySegment<byte>(raw)).AsQueryResponse(new NameServer(ip));

Assert.Equal(result.Answers.Count, 1);
Assert.Equal(1, result.Answers.Count);
var resultAnswer = result.Answers.OfType<ARecord>().First();
Assert.Equal(resultAnswer.Address.ToString(), ip.ToString());
Assert.Equal(resultAnswer.DomainName.Value, "query.");
Assert.Equal(resultAnswer.RawDataLength, 4);
Assert.Equal(resultAnswer.RecordClass, QueryClass.IN);
Assert.Equal(resultAnswer.RecordType, ResourceRecordType.A);
Assert.Equal("query.", resultAnswer.DomainName.Value);
Assert.Equal(4, resultAnswer.RawDataLength);
Assert.Equal(QueryClass.IN, resultAnswer.RecordClass);
Assert.Equal(ResourceRecordType.A, resultAnswer.RecordType);
Assert.True(resultAnswer.TimeToLive == 100);
Assert.True(result.Header.Id == 42);
Assert.True(result.Header.AnswerCount == 1);
Expand Down
22 changes: 11 additions & 11 deletions test/DnsClient.Tests/DnsRecordFactoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void DnsRecordFactory_PTRRecordEmptyName()

var result = factory.GetRecord(info) as PtrRecord;

Assert.Equal(result.PtrDomainName.Value, ".");
Assert.Equal(".", result.PtrDomainName.Value);
}

[Fact]
Expand Down Expand Up @@ -65,7 +65,7 @@ public void DnsRecordFactory_MBRecord()
var result = factory.GetRecord(info) as MbRecord;

Assert.Equal(result.MadName, name);
Assert.Equal(result.MadName.Original, "müsli.de.");
Assert.Equal("müsli.de.", result.MadName.Original);
}

[Fact]
Expand Down Expand Up @@ -138,7 +138,7 @@ public void DnsRecordFactory_NSRecordEmptyName()

var result = factory.GetRecord(info) as NsRecord;

Assert.Equal(result.NSDName.Value, ".");
Assert.Equal(".", result.NSDName.Value);
}

[Fact]
Expand Down Expand Up @@ -188,8 +188,8 @@ public void DnsRecordFactory_MXRecordEmptyName()

var result = factory.GetRecord(info) as MxRecord;

Assert.Equal(result.Preference, 256);
Assert.Equal(result.Exchange.Value, ".");
Assert.Equal(256, result.Preference);
Assert.Equal(".", result.Exchange.Value);
}

[Fact]
Expand All @@ -206,7 +206,7 @@ public void DnsRecordFactory_MXRecord()

var result = factory.GetRecord(info) as MxRecord;

Assert.Equal(result.Preference, 1);
Assert.Equal(1, result.Preference);
Assert.Equal(result.Exchange, name);
}

Expand All @@ -231,8 +231,8 @@ public void DnsRecordFactory_SOARecord()

var result = factory.GetRecord(info) as SoaRecord;

Assert.Equal(result.MName.Value, ".");
Assert.Equal(result.RName.Value, ".");
Assert.Equal(".", result.MName.Value);
Assert.Equal(".", result.RName.Value);
Assert.True(result.Serial == 1);
Assert.True(result.Refresh == 2);
Assert.True(result.Retry == 3);
Expand Down Expand Up @@ -318,7 +318,7 @@ public void DnsRecordFactory_TXTRecord()

var result = factory.GetRecord(info) as TxtRecord;

Assert.Equal(result.EscapedText.Count, 2);
Assert.Equal(2, result.EscapedText.Count);
Assert.Equal(result.EscapedText.ElementAt(0), textA);
Assert.Equal(result.EscapedText.ElementAt(1), textB);
}
Expand All @@ -341,9 +341,9 @@ public void DnsRecordFactory_SpecialChars()

var result = factory.GetRecord(info) as TxtRecord;

Assert.Equal(result.EscapedText.Count, 2);
Assert.Equal(2, result.EscapedText.Count);
Assert.Equal(result.Text.ElementAt(0), textA);
Assert.Equal(result.EscapedText.ElementAt(0), "\\\"\\195\\164\\195\\182\\195\\188 \\\\slash/! @bla.com \\\"");
Assert.Equal("\\\"\\195\\164\\195\\182\\195\\188 \\\\slash/! @bla.com \\\"", result.EscapedText.ElementAt(0));
Assert.Equal(result.Text.ElementAt(1), textB);
Assert.Equal(result.EscapedText.ElementAt(1), textB);
}
Expand Down
5 changes: 1 addition & 4 deletions test/DnsClient.Tests/DnsStringTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void DnsString_SimpleValidWithRoot()
{
var name = DnsString.Parse("abc.xyz.example.com.");

Assert.Equal(name.Value, "abc.xyz.example.com.");
Assert.Equal("abc.xyz.example.com.", name.Value);
}

[Fact]
Expand Down Expand Up @@ -119,7 +119,6 @@ public void DnsString_Hashcode()
DnsString name = DnsString.Parse(val);
DnsString name2 = DnsString.Parse(val);

Assert.NotNull(name.GetHashCode());
Assert.True(name.GetHashCode().Equals(name2.GetHashCode()));
}

Expand All @@ -129,8 +128,6 @@ public void DnsString_HashcodeNot()
var val = "Aäb.bÜlöb.cscöälüpqläö.d.com.";
DnsString name = DnsString.Parse(val);
DnsString name2 = DnsString.Parse("asdasd");

Assert.NotNull(name.GetHashCode());
Assert.False(name.GetHashCode().Equals(name2.GetHashCode()));
}

Expand Down
Loading

0 comments on commit eb901f6

Please sign in to comment.