Compilation warns

broken/ef
Paul Schneider 2 years ago
parent 217cc49019
commit 4191513eef
22 changed files with 72 additions and 57 deletions

@ -2,6 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
<NoWarn>NETSDK1138</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

@ -166,7 +166,7 @@ namespace isn
pushoptions.WriteOptionDescriptions(Console.Out); pushoptions.WriteOptionDescriptions(Console.Out);
return; return;
} }
List<PushReport> reports = PushPkg(pargs); List<PushReport> reports = await PushPkgAsync(pargs);
Console.WriteLine(JsonConvert.SerializeObject(reports)); Console.WriteLine(JsonConvert.SerializeObject(reports));
pushKO = reports.Count(r => !r.OK && !r.AlreadyPresent); pushKO = reports.Count(r => !r.OK && !r.AlreadyPresent);
} }

@ -3,30 +3,23 @@ using System.IO;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using isn.Abstract;
using Newtonsoft.Json; using Newtonsoft.Json;
using isn.Abstract;
namespace isn namespace isn
{ {
public static class SourceHelpers public static class SourceHelpers
{ {
public static ApiIndexViewModel GetServerResources(string url) public static async Task<ApiIndexViewModel> GetServerResourcesAsync(string url)
{ {
HttpClient client = new HttpClient(); HttpClient client = new HttpClient();
ApiIndexViewModel result = null; ApiIndexViewModel result = null;
// var json = await client.GetStringAsync(new System.Uri(url)); // var json = await client.GetStringAsync(new System.Uri(url));
try
{
Task.Run(async () =>
{
var response = await client.GetStringAsync(url); var response = await client.GetStringAsync(url);
result = JsonConvert.DeserializeObject<ApiIndexViewModel>(response); result = JsonConvert.DeserializeObject<ApiIndexViewModel>(response);
}).Wait();
}
catch(Exception ex)
{
throw;
}
return result; return result;
} }

@ -9,12 +9,12 @@ namespace isn
{ {
public class PushCommand public class PushCommand
{ {
static public PushReport Run(string pkg, string source) static public async Task<PushReport> RunAsync(string pkg, string source)
{ {
if (source == null) source = Program.Settings.DefaultSource; if (source == null) source = Program.Settings.DefaultSource;
if (source == null) throw new InvalidOperationException("source is null"); if (source == null) throw new InvalidOperationException("source is null");
string apikey = Program.Protector.UnProtect(Program.Settings.Sources[source].ApiKey); string apikey = Program.Protector.UnProtect(Program.Settings.Sources[source].ApiKey);
var resources = SourceHelpers.GetServerResources(source); var resources = await SourceHelpers.GetServerResourcesAsync(source);
if (resources.Resources == null) if (resources.Resources == null)
throw new InvalidOperationException("source gave no resource"); throw new InvalidOperationException("source gave no resource");
if (!resources.Resources.Any(res => res.Type == "PackagePublish/3.5.0")) if (!resources.Resources.Any(res => res.Type == "PackagePublish/3.5.0"))

@ -9,13 +9,13 @@ namespace isn
partial class Program partial class Program
{ {
public static List<PushReport> PushPkg(IEnumerable<string> pkgs) public static async Task<List<PushReport>> PushPkgAsync(IEnumerable<string> pkgs)
{ {
List<PushReport> pushReports = new List<PushReport>(); List<PushReport> pushReports = new List<PushReport>();
foreach (string pkg in pkgs) foreach (string pkg in pkgs)
{ {
var report = PushCommand.Run(pkg, source); var report = await PushCommand.RunAsync(pkg, source);
pushReports.Add(report); pushReports.Add(report);
} }

@ -9,6 +9,7 @@
<IsPackable>true</IsPackable> <IsPackable>true</IsPackable>
<PackageLicenseExpression>WTFPL</PackageLicenseExpression> <PackageLicenseExpression>WTFPL</PackageLicenseExpression>
<IsTool>true</IsTool> <IsTool>true</IsTool>
<NoWarn>NETSDK1138</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

@ -0,0 +1,31 @@
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NuGet.Versioning;
using isnd.Data;
using isnd.Entities;
using Unleash;
using isnd.Services;
using isnd.ViewModels;
using System.Threading.Tasks;
using isnd.Interfaces;
using isn.Abstract;
namespace isnd.Controllers
{
public partial class PackagesController : Controller
{
[HttpGet(_pkgRootPrefix + ApiConfig.Base)]
public IActionResult ApiIndex()
{
return Ok(new ApiIndexViewModel{ Version = PackageManager.BASE_API_LEVEL, Resources = _resources });
}
}
}

@ -1,4 +1,5 @@
using isnd.Services; using isnd.Services;
using isnd.Entities;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace isnd.Controllers namespace isnd.Controllers

@ -3,7 +3,7 @@ using System.Threading.Tasks;
using isnd.Data.Catalog; using isnd.Data.Catalog;
using isnd.Helpers; using isnd.Helpers;
using isnd.Services; using isnd.Services;
using isnd.ViewModels; using isnd.Entities;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;

@ -49,12 +49,5 @@ namespace isnd.Controllers
_unleashĈlient = unleashĈlient; _unleashĈlient = unleashĈlient;
_resources = _packageManager.GetResources(_unleashĈlient).ToArray(); _resources = _packageManager.GetResources(_unleashĈlient).ToArray();
} }
[HttpGet(_pkgRootPrefix + ApiConfig.Base)]
public IActionResult ApiIndex()
{
return Ok(new ApiIndexViewModel{ Version = PackageManager.BASE_API_LEVEL, Resources = _resources });
}
} }
}
}

@ -1,6 +1,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using isnd.Helpers; using isnd.Helpers;
using isnd.Entities;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using isnd.Attributes; using isnd.Attributes;
namespace isnd.Controllers namespace isnd.Controllers

@ -2,15 +2,13 @@ using System.ComponentModel.DataAnnotations;
using System.IO; using System.IO;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using isnd.Attributes; using isnd.Attributes;
using isnd.Entities;
namespace isnd.Controllers namespace isnd.Controllers
{ {
public partial class PackagesController public partial class PackagesController
{ {
// TODO GET GET {@id}/{LOWER_ID}/{LOWER_VERSION}/{LOWER_ID}.{LOWER_VERSION}.nupkg // Web get nupkg
// LOWER_ID URL string yes The package ID, lowercase
// LOWER_VERSION URL string yes The package version, normalized and lowercased
// response 200 : the package
[HttpGet(_pkgRootPrefix + ApiConfig.Get + "/{id}/{lower}/{idf}-{lowerf}.nupkg")] [HttpGet(_pkgRootPrefix + ApiConfig.Get + "/{id}/{lower}/{idf}-{lowerf}.nupkg")]
public IActionResult GetPackage( public IActionResult GetPackage(
[FromRoute][SafeName][Required] string id, [FromRoute][SafeName][Required] string id,
@ -30,8 +28,7 @@ namespace isnd.Controllers
return File(pkgfi.OpenRead(), "application/zip; charset=binary"); return File(pkgfi.OpenRead(), "application/zip; charset=binary");
} }
// TODO GET {@id}/{LOWER_ID}/{LOWER_VERSION}/{LOWER_ID}.nuspec // Web get spec
// response 200 : the nuspec
[HttpGet(_pkgRootPrefix + ApiConfig.Get + "/{id}/{lower}/{idf}-{lowerf}.nuspec")] [HttpGet(_pkgRootPrefix + ApiConfig.Get + "/{id}/{lower}/{idf}-{lowerf}.nuspec")]
public IActionResult GetNuspec( public IActionResult GetNuspec(
[FromRoute][SafeName][Required] string id, [FromRoute][SafeName][Required] string id,

@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using NuGet.Versioning; using NuGet.Versioning;
using isnd.Entities;
namespace isnd.Controllers namespace isnd.Controllers
{ {

@ -13,6 +13,7 @@ using NuGet.Packaging.Core;
using NuGet.Versioning; using NuGet.Versioning;
using isnd.Data; using isnd.Data;
using isnd.Helpers; using isnd.Helpers;
using isnd.Entities;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using isnd.Data.Catalog; using isnd.Data.Catalog;

@ -2,6 +2,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using isnd.Entities;
namespace isnd.Controllers namespace isnd.Controllers
{ {

@ -10,7 +10,7 @@ namespace isnd.Controllers
public partial class PackagesController public partial class PackagesController
{ {
// GET: PackageVersion // Web search
public async Task<IActionResult> Index(PackageIndexViewModel model) public async Task<IActionResult> Index(PackageIndexViewModel model)
{ {
var applicationDbContext = _dbContext.Packages.Include(p => p.Versions).Where( var applicationDbContext = _dbContext.Packages.Include(p => p.Versions).Where(

@ -1,4 +1,4 @@
namespace isnd namespace isnd.Entities
{ {
public static class ApiConfig public static class ApiConfig
{ {
@ -15,5 +15,7 @@ namespace isnd
public const string Delete = "delete"; public const string Delete = "delete";
public const string Registration = "registration";
} }
} }

@ -71,33 +71,23 @@ namespace isnd.Services
Type = "SearchQueryService/" + BASE_API_LEVEL, Type = "SearchQueryService/" + BASE_API_LEVEL,
Comment = "Search Query service" Comment = "Search Query service"
}); });
/*
{
"@id": "https://api-v2v3search-0.nuget.org/query",
"@type": "SearchQueryService/3.0.0-rc",
"comment": "Query endpoint of NuGet Search service (primary) used by RC clients"
},
if (unleashClient.IsEnabled("pkg-catalog", false)) if (unleashClient.IsEnabled("pkg-catalog", false))
res.Add( res.Add(
new Resource new Resource
{ {
Id = extUrl + ApiConfig.Catalog, Id = extUrl + ApiConfig.Catalog,
Type = "Catalog/3.0.0", Type = "Catalog/"+ BASE_API_LEVEL,
Comment = "Package Catalog Index" Comment = "Package Catalog Index"
});*/ });
if (unleashClient.IsEnabled("pkg-registration", false))
/* TODO ? { res.Add(
new Resource
"@id": "https://api.nuget.org/v3/registration5-gz-semver2/", {
"@type": "RegistrationsBaseUrl/Versioned", Id = extUrl + ApiConfig.Registration,
"clientVersion": "4.3.0-alpha", Type = "Catalog/" + BASE_API_LEVEL,
"comment": "Base URL of Azure storage where NuGet package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages." Comment = "Base URL of storage where isn package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
});
},
*/
return res; return res;
} }
public PackageIndexViewModel SearchByName(string query, public PackageIndexViewModel SearchByName(string query,

@ -6,6 +6,7 @@
<PackageVersion>1.0.1</PackageVersion> <PackageVersion>1.0.1</PackageVersion>
<IsPackable>true</IsPackable> <IsPackable>true</IsPackable>
<PackageLicenseExpression>WTFPL</PackageLicenseExpression> <PackageLicenseExpression>WTFPL</PackageLicenseExpression>
<NoWarn>NETSDK1138</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

@ -57,10 +57,10 @@ dataTable.Rows.Add(dataRow);
Assert.NotNull(vm.Resources); Assert.NotNull(vm.Resources);
} }
[Fact] [Fact]
public void TestPush() public async Task TestPush()
{ {
Program.LoadConfig(); Program.LoadConfig();
var report = Program.PushPkg(new string[] { "/home/paul/Nupkgs/Yavsc.Abstract.1.0.8.nupkg" }); var report = await Program.PushPkgAsync(new string[] { "/home/paul/Nupkgs/Yavsc.Abstract.1.0.8.nupkg" });
} }
[Fact] [Fact]

@ -2,8 +2,8 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netcoreapp2.1</TargetFrameworks> <TargetFrameworks>netcoreapp2.1</TargetFrameworks>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<NoWarn>NETSDK1138</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

@ -5,6 +5,7 @@
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<UserSecretsId>d7144e46-4e63-4391-ba86-64b61f6e7be4</UserSecretsId> <UserSecretsId>d7144e46-4e63-4391-ba86-64b61f6e7be4</UserSecretsId>
<NoWarn>NETSDK1138</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

Loading…