Skip to content

Commit 66119f0

Browse files
committed
Merge branch 'master' of https://github.com/aws/porting-assistant-dotnet-datastore into comsemer-webforms-as-action
2 parents 0000d49 + f0735c7 commit 66119f0

File tree

8 files changed

+359
-6
lines changed

8 files changed

+359
-6
lines changed

NuGet.Config

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
5+
<add key="dotnet" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
6+
<add key="encore-nuget" value="https://s3-us-west-2.amazonaws.com/aws.portingassistant.dotnet.download/nuget/index.json" />
7+
</packageSources>
8+
</configuration>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Porting Assistant for .NET quickly scans .NET Framework applications to identify
66
### Porting Assistant Dotnet DataStore
77
This repository contains the location of data store in S3. The data store contains data files that show package and API compatibility with .NET Core and .NET Standard.
88

9-
* Porting assistant uses these data files for finding the compatibility of packages and their APIs
9+
* Porting assistant uses these data files for finding the compatibility of packages and their APIs.
1010
* For each NuGet package in nuget.org, a separate Json file is defined. Each file captures compatibility information of all its packaged versions.
1111
* It shows compatibility information for all the NuGet packages available in nuget.org - 211k unique packages, 2.5 millions packaged versions (The numbers could change over time).
1212

RecommendationTools/RecommendationBatchUpdater/RecommendationBatchUpdater.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>netcoreapp3.1</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="CTA.Rules.Models" Version="1.10.16-alpha-gcdfac9e409" />
9+
<PackageReference Include="CTA.Rules.Models" Version="2.0.3" />
1010
</ItemGroup>
1111

1212
<ItemGroup>

RecommendationTools/RecommendationTools.sln

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
2-
# Visual Studio Version 16
3-
VisualStudioVersion = 16.0.31729.503
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.0.32126.317
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RecommendationValidator", "RecommendationValidator\RecommendationValidator.csproj", "{DB3D0373-8483-4CEB-96C1-F1B0966D7483}"
66
EndProject
7-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RecommendationBatchUpdater", "RecommendationBatchUpdater\RecommendationBatchUpdater.csproj", "{BAE409F1-F59A-458C-8F94-D4ED943A4E79}"
7+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RecommendationBatchUpdater", "RecommendationBatchUpdater\RecommendationBatchUpdater.csproj", "{BAE409F1-F59A-458C-8F94-D4ED943A4E79}"
8+
EndProject
9+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PostSyncTests", "UnitTests\PostSyncTests.csproj", "{853E9367-AAFE-4CEA-9FAD-867BD09BB978}"
810
EndProject
911
Global
1012
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -20,6 +22,10 @@ Global
2022
{BAE409F1-F59A-458C-8F94-D4ED943A4E79}.Debug|Any CPU.Build.0 = Debug|Any CPU
2123
{BAE409F1-F59A-458C-8F94-D4ED943A4E79}.Release|Any CPU.ActiveCfg = Release|Any CPU
2224
{BAE409F1-F59A-458C-8F94-D4ED943A4E79}.Release|Any CPU.Build.0 = Release|Any CPU
25+
{853E9367-AAFE-4CEA-9FAD-867BD09BB978}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26+
{853E9367-AAFE-4CEA-9FAD-867BD09BB978}.Debug|Any CPU.Build.0 = Debug|Any CPU
27+
{853E9367-AAFE-4CEA-9FAD-867BD09BB978}.Release|Any CPU.ActiveCfg = Release|Any CPU
28+
{853E9367-AAFE-4CEA-9FAD-867BD09BB978}.Release|Any CPU.Build.0 = Release|Any CPU
2329
EndGlobalSection
2430
GlobalSection(SolutionProperties) = preSolution
2531
HideSolutionNode = FALSE
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
7+
<IsPackable>false</IsPackable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="AWSSDK.S3" Version="3.7.7.23" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
13+
<PackageReference Include="NUnit" Version="3.13.2" />
14+
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0" />
15+
<PackageReference Include="coverlet.collector" Version="3.1.0" />
16+
</ItemGroup>
17+
18+
</Project>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using NUnit.Framework;
2+
using System;
3+
using System.IO;
4+
using System.IO.Compression;
5+
using System.Linq;
6+
using System.Net.Http;
7+
using System.Threading.Tasks;
8+
9+
namespace PostSyncTests
10+
{
11+
/// <summary>
12+
/// These tests are made to be run automatically after a merge and sync to the public S3 bucket. This is needed
13+
/// in order to validate that the public S3 bucket is up to date with the repository and that the sync is working.
14+
/// This test always uses the master branch, not your local feature branch since that is what should always be in
15+
/// sync with S3.
16+
/// </summary>
17+
public class S3SyncTests
18+
{
19+
private const string S3UrlPrefix = "https://s3.us-west-2.amazonaws.com/aws.portingassistant.dotnet.datastore/recommendationsync";
20+
private const string TempExtractDir = "masterBranchCode";
21+
22+
[TearDown]
23+
[SetUp]
24+
public static void SetupAndTearDown()
25+
{
26+
if (Directory.Exists(TempExtractDir))
27+
{
28+
Directory.Delete(TempExtractDir, true);
29+
}
30+
}
31+
32+
[Test]
33+
public async Task ValidateS3RecommendationContentMatchesRepository()
34+
{
35+
using var httpClient = new HttpClient();
36+
// Use always master branch since that is the only branch that should be in sync with S3
37+
var zipBytes = await httpClient.GetByteArrayAsync("https://github.com/aws/porting-assistant-dotnet-datastore/archive/refs/heads/master.zip");
38+
await File.WriteAllBytesAsync("github.zip", zipBytes);
39+
Directory.CreateDirectory(TempExtractDir);
40+
ZipFile.ExtractToDirectory("github.zip", TempExtractDir);
41+
var pathToRepoRecs = $@"{TempExtractDir}\porting-assistant-dotnet-datastore-master\recommendation";
42+
var pathToRepoTemplates = $@"{TempExtractDir}\porting-assistant-dotnet-datastore-master\Templates";
43+
44+
var allRepoFilesToCheck = Directory.EnumerateFiles(pathToRepoRecs, "*", SearchOption.AllDirectories).ToList();
45+
var allRepoTemplates = Directory.EnumerateFiles(pathToRepoTemplates, "*", SearchOption.AllDirectories).ToList();
46+
47+
allRepoFilesToCheck.AddRange(allRepoTemplates);
48+
49+
Assert.Multiple(async () =>
50+
{
51+
foreach(var file in allRepoFilesToCheck)
52+
{
53+
var s3ObjectPath = $"{S3UrlPrefix}/{file.Replace(@$"{TempExtractDir}\porting-assistant-dotnet-datastore-master\", "").Replace(@"\", "/")}";
54+
var s3Content = await httpClient.GetStringAsync(s3ObjectPath);
55+
var localContent = await File.ReadAllTextAsync(file);
56+
localContent = localContent.Replace("\r\n", "\n", StringComparison.Ordinal);
57+
s3Content = s3Content.Replace("\r\n", "\n", StringComparison.Ordinal);
58+
Assert.AreEqual(localContent, s3Content, $"Content didn't match for file {file}");
59+
}
60+
});
61+
}
62+
}
63+
}
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/*
2+
3+
using Microsoft.AspNetCore.Http.Extensions;
4+
using System.Net;
5+
6+
namespace Modernize.Web.Mvc.Controllers
7+
{
8+
public static class MonolithService
9+
{
10+
//TODO Add Service Host
11+
private static string ServiceHost = "";
12+
13+
//TODO Add Service Port
14+
private static string ServicePort = "";
15+
private static string ServiceUrl = $"https://{ServiceHost}";
16+
private static HttpClientHandler handler = new HttpClientHandler()
17+
{
18+
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
19+
};
20+
private static HttpClient client = new HttpClient(handler);
21+
22+
23+
public static async Task<string> CreateRequestAsync(HttpRequestMessage httpRequest, Microsoft.AspNetCore.Routing.RouteData routeData)
24+
{
25+
string? actionName = routeData?.Values["action"]?.ToString();
26+
string? controllerName = routeData?.Values["controller"]?.ToString();
27+
var httpMessage = GetRequestMessage(httpRequest, controllerName, actionName);
28+
return await InvokeRequestAsync(httpMessage);
29+
}
30+
31+
public static string CreateRequest(HttpRequestMessage httpRequest, Microsoft.AspNetCore.Routing.RouteData routeData)
32+
{
33+
string? actionName = routeData?.Values["action"]?.ToString();
34+
string? controllerName = routeData?.Values["controller"]?.ToString();
35+
var httpMessage = GetRequestMessage(httpRequest, controllerName, actionName);
36+
return InvokeRequest(httpMessage);
37+
}
38+
39+
40+
public static async Task<string> CreateRequestAsync(HttpRequest httpRequest, Microsoft.AspNetCore.Routing.RouteData routeData)
41+
{
42+
string? actionName = routeData?.Values["action"]?.ToString();
43+
string? controllerName = routeData?.Values["controller"]?.ToString();
44+
var httpMessage = GetRequestMessage(httpRequest, controllerName, actionName);
45+
return await InvokeRequestAsync(httpMessage);
46+
}
47+
48+
public static string CreateRequest(HttpRequest httpRequest, Microsoft.AspNetCore.Routing.RouteData routeData)
49+
{
50+
string? actionName = routeData?.Values["action"]?.ToString();
51+
string? controllerName = routeData?.Values["controller"]?.ToString();
52+
var httpMessage = GetRequestMessage(httpRequest, controllerName, actionName);
53+
return InvokeRequest(httpMessage);
54+
}
55+
56+
private static async Task<string> InvokeRequestAsync(HttpRequestMessage requestMessage)
57+
{
58+
var result = await client.SendAsync(requestMessage).ConfigureAwait(false);
59+
var stringResult = await result.Content.ReadAsStringAsync().ConfigureAwait(false);
60+
return stringResult;
61+
}
62+
63+
private static string InvokeRequest(HttpRequestMessage requestMessage)
64+
{
65+
var result = client.SendAsync(requestMessage).Result;
66+
var stringResult = result.Content.ReadAsStringAsync().Result;
67+
return stringResult;
68+
}
69+
70+
private static HttpRequestMessage GetRequestMessage(HttpRequestMessage httpRequestMessage, string? controllerName, string? actionName)
71+
{
72+
var currentUri = httpRequestMessage.RequestUri;
73+
var uriBuilder = new UriBuilder($"{ServiceUrl}/{controllerName}/{actionName}")
74+
{
75+
Host = ServiceHost,
76+
Port = int.Parse(ServicePort),
77+
Fragment = currentUri?.Fragment,
78+
Scheme = currentUri?.Scheme,
79+
Path = currentUri?.PathAndQuery
80+
};
81+
82+
var newRequest = httpRequestMessage;
83+
newRequest.RequestUri = uriBuilder.Uri;
84+
return newRequest;
85+
}
86+
private static HttpRequestMessage GetRequestMessage(HttpRequest httpRequest, string controllerName, string actionName)
87+
{
88+
var httpMethod = new HttpMethod(httpRequest.Method);
89+
var currentUri = new Uri(httpRequest.GetDisplayUrl());
90+
var uriBuilder = new UriBuilder($"{ServiceUrl}/{controllerName}/{actionName}")
91+
{
92+
Host = ServiceHost,
93+
Port = int.Parse(ServicePort),
94+
Fragment = currentUri.Fragment,
95+
Scheme = currentUri.Scheme,
96+
Path = currentUri.PathAndQuery
97+
};
98+
var requestMessage = new HttpRequestMessage(httpMethod, uriBuilder.Uri);
99+
var currentHeaders = httpRequest.Headers.Keys.ToArray();
100+
101+
if (httpMethod == HttpMethod.Post || httpMethod == HttpMethod.Put)
102+
{
103+
var streamReader = new StreamReader(httpRequest.Body).ReadToEnd();
104+
requestMessage.Content = new StringContent(streamReader);
105+
requestMessage.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(httpRequest.ContentType);
106+
//requestMessage.Content.Headers.ContentEncoding.Add(httpRequest.ContentEncoding.HeaderName);
107+
requestMessage.Content.Headers.ContentLength = httpRequest.ContentLength;
108+
}
109+
for (int i = 0; i < currentHeaders.Length; i++)
110+
{
111+
try
112+
{
113+
if (currentHeaders[i] == "Host")
114+
{
115+
requestMessage?.Headers.Add(currentHeaders[i], ServiceHost);
116+
}
117+
else if (currentHeaders[i].StartsWith("Content-"))
118+
{
119+
requestMessage?.Content?.Headers.TryAddWithoutValidation(currentHeaders[i], httpRequest.Headers[currentHeaders[i]].FirstOrDefault());
120+
}
121+
else
122+
{
123+
requestMessage?.Headers.TryAddWithoutValidation(currentHeaders[i], httpRequest.Headers[currentHeaders[i]].FirstOrDefault());
124+
}
125+
}
126+
catch (Exception ex)
127+
{
128+
}
129+
}
130+
return requestMessage;
131+
}
132+
}
133+
}
134+
135+
136+
*/

0 commit comments

Comments
 (0)