Skip to content

Commit

Permalink
Torrent WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Krusen committed Oct 12, 2019
1 parent 0a86b42 commit 1116b24
Show file tree
Hide file tree
Showing 24 changed files with 113 additions and 23 deletions.
3 changes: 1 addition & 2 deletions BencodeNET.Tests/BencodeNET.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;netcoreapp2.0;netcoreapp2.2;netcoreapp3.0</TargetFrameworks>
<LangVersion>7.3</LangVersion>
</PropertyGroup>

<ItemGroup>
<None Update="Files\ubuntu-14.10-desktop-amd64.iso.torrent" CopyToOutputDirectory="PreserveNewest" />
<None Update="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

Expand Down
19 changes: 19 additions & 0 deletions BencodeNET.Torrents.Tests/BencodeNET.Torrents.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;netcoreapp2.0;netcoreapp2.2;netcoreapp3.0</TargetFrameworks>
<LangVersion>7.3</LangVersion>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\BencodeNET.Tests\BencodeNET.Tests.csproj" />
<ProjectReference Include="..\BencodeNET.Torrents\BencodeNET.Torrents.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="Files\ubuntu-14.10-desktop-amd64.iso.torrent">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
using BencodeNET.IO;
using BencodeNET.Objects;
using BencodeNET.Parsing;
using BencodeNET.Torrents;
using BencodeNET.Tests;
using FluentAssertions;
using NSubstitute;
using Xunit;

namespace BencodeNET.Tests.Torrents
namespace BencodeNET.Torrents.Tests
{
public class TorrentParserTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
using System.Text;
using BencodeNET.Exceptions;
using BencodeNET.Objects;
using BencodeNET.Torrents;
using BencodeNET.Tests;
using FluentAssertions;
using Xunit;

namespace BencodeNET.Tests.Torrents
namespace BencodeNET.Torrents.Tests
{
public class TorrentTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
using System.Linq;
using BencodeNET.Objects;
using BencodeNET.Parsing;
using BencodeNET.Torrents;
using BencodeNET.Tests;
using FluentAssertions;
using NSubstitute;
using Xunit;

namespace BencodeNET.Tests.Torrents
namespace BencodeNET.Torrents.Tests
{
public class TorrentUtilTests
{
Expand Down
47 changes: 47 additions & 0 deletions BencodeNET.Torrents/BencodeNET.Torrents.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
<LangVersion>7.3</LangVersion>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<CodeAnalysisRuleSet>BencodeNET.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<!-- Needed for code coverage -->
<PropertyGroup>
<DebugType>full</DebugType>
</PropertyGroup>

<PropertyGroup>
<PackageId>BencodeNET.Torrents</PackageId>
<Version>$(SemVer)</Version>
<Authors>Søren Kruse</Authors>
<Company />
<Product>BencodeNET.Torrents</Product>
<Description>A library for working with torrent files</Description>
<PackageLicenseExpression>Unlicense</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/Krusen/BencodeNET</PackageProjectUrl>
<PackageIcon>icon.png</PackageIcon>
<RepositoryUrl>https://github.com/Krusen/BencodeNET</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageTags>bencode;torrent;torrents;torrentfile</PackageTags>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<IncludeSource>True</IncludeSource>
<IncludeSymbols>True</IncludeSymbols>
</PropertyGroup>

<ItemGroup>
<None Include="../Assets/icon.png" Pack="true" PackagePath="/" />
</ItemGroup>

<ItemGroup>
<!--<PackageReference Include="System.Buffers" Version="4.5.0" />
<PackageReference Include="System.IO.Pipelines" Version="4.6.0" />-->
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BencodeNET\BencodeNET.csproj" />
</ItemGroup>

</Project>
10 changes: 10 additions & 0 deletions BencodeNET.Torrents/BencodeNET.ruleset
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Microsoft Managed Recommended Rules" Description="These rules focus on the most critical problems in your code, including potential security holes, application crashes, and other important logic and design errors. It is recommended to include this rule set in any custom rule set you create for your projects." ToolsVersion="10.0">
<Localization ResourceAssembly="Microsoft.VisualStudio.CodeAnalysis.RuleSets.Strings.dll" ResourceBaseName="Microsoft.VisualStudio.CodeAnalysis.RuleSets.Strings.Localized">
<Name Resource="MinimumRecommendedRules_Name" />
<Description Resource="MinimumRecommendedRules_Description" />
</Localization>
<Rules AnalyzerId="Microsoft.VisualStudio.Threading.Analyzers" RuleNamespace="Microsoft.VisualStudio.Threading.Analyzers">
<Rule Id="VSTHRD111" Action="Error" />
</Rules>
</RuleSet>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Threading;
using System.Threading.Tasks;
using BencodeNET.Exceptions;
using BencodeNET.IO;
using BencodeNET.Objects;

namespace BencodeNET.Torrents
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions BencodeNET.Torrents/UtilityExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.Linq;

namespace BencodeNET.Torrents
{
internal static class UtilityExtensions
{
public static IEnumerable<T> Flatten<T>(this IEnumerable<IEnumerable<T>> source)
{
return source.SelectMany(x => x);
}
}
}
16 changes: 14 additions & 2 deletions BencodeNET.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.3
# Visual Studio Version 16
VisualStudioVersion = 16.0.29403.142
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{65E984B8-653C-4BCD-AE37-4E21497B5B87}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -18,6 +18,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BencodeNET", "BencodeNET\Be
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BencodeNET.Tests", "BencodeNET.Tests\BencodeNET.Tests.csproj", "{5992CAC5-C0D3-4255-BFD7-C11C07969900}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BencodeNET.Torrents", "BencodeNET.Torrents\BencodeNET.Torrents.csproj", "{7334E3CD-AF7F-495F-9E23-5EEC662C6962}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BencodeNET.Torrents.Tests", "BencodeNET.Torrents.Tests\BencodeNET.Torrents.Tests.csproj", "{3052ABD9-490A-4F24-BC2D-4291364DF3B9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -32,6 +36,14 @@ Global
{5992CAC5-C0D3-4255-BFD7-C11C07969900}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5992CAC5-C0D3-4255-BFD7-C11C07969900}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5992CAC5-C0D3-4255-BFD7-C11C07969900}.Release|Any CPU.Build.0 = Release|Any CPU
{7334E3CD-AF7F-495F-9E23-5EEC662C6962}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7334E3CD-AF7F-495F-9E23-5EEC662C6962}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7334E3CD-AF7F-495F-9E23-5EEC662C6962}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7334E3CD-AF7F-495F-9E23-5EEC662C6962}.Release|Any CPU.Build.0 = Release|Any CPU
{3052ABD9-490A-4F24-BC2D-4291364DF3B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3052ABD9-490A-4F24-BC2D-4291364DF3B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3052ABD9-490A-4F24-BC2D-4291364DF3B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3052ABD9-490A-4F24-BC2D-4291364DF3B9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 2 additions & 2 deletions BencodeNET/BencodeNET.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
Expand Down Expand Up @@ -26,7 +26,7 @@
<RepositoryUrl>https://github.com/Krusen/BencodeNET</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageTags>bencode;torrent;torrents</PackageTags>
<PackageTags>bencode</PackageTags>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<IncludeSource>True</IncludeSource>
<IncludeSymbols>True</IncludeSymbols>
Expand Down
3 changes: 0 additions & 3 deletions BencodeNET/Objects/BObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ namespace BencodeNET.Objects
/// </summary>
public abstract class BObject : IBObject
{
internal BObject()
{ }

/// <summary>
/// Calculates the (encoded) size of the object in bytes.
/// </summary>
Expand Down
8 changes: 1 addition & 7 deletions BencodeNET/UtilityExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Pipelines;
using System.Linq;
using System.Text;

namespace BencodeNET
Expand All @@ -24,11 +23,6 @@ public static MemoryStream AsStream(this string str, Encoding encoding)
return dictionary.TryGetValue(key, out var value) ? value : default;
}

public static IEnumerable<T> Flatten<T>(this IEnumerable<IEnumerable<T>> source)
{
return source.SelectMany(x => x);
}

public static int DigitCount(this int value) => DigitCount((long) value);

public static int DigitCount(this long value)
Expand Down

0 comments on commit 1116b24

Please sign in to comment.