Skip to content

Commit ae26935

Browse files
Migrate to net5
1 parent 3895012 commit ae26935

File tree

212 files changed

+1110
-9319
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

212 files changed

+1110
-9319
lines changed

Adapter/Adapter.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<TargetFramework>net5.0</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>

Adapter/NoCaching/Demo.cs

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using MoreLinq;
45

56
namespace Adapter.NoCaching
67
{
7-
public class Demo
8+
public static class Demo
89
{
9-
private static readonly List<VectorObject> vectorObjects = new List<VectorObject>
10+
private static readonly List<VectorObject> VectorObjects = new()
1011
{
1112
new VectorRectangle(1, 1, 10, 10),
1213
new VectorRectangle(3, 3, 6, 6)
1314
};
1415

1516
// the interface we have
16-
public static void DrawPoint(Point p)
17+
private static void DrawPoint(Point p)
1718
{
1819
Console.Write(".");
1920
}
2021

21-
private static void Main()
22+
public static void Main()
2223
{
2324
Draw();
2425
Draw();
2526
}
2627

2728
private static void Draw()
2829
{
29-
foreach (var vo in vectorObjects)
30-
foreach (var line in vo)
31-
{
32-
var adapter = new LineToPointAdapter(line);
30+
foreach (var adapter in from vo in VectorObjects from line in vo select new LineToPointAdapter(line))
3331
adapter.ForEach(DrawPoint);
34-
}
3532
}
3633
}
3734
}

Adapter/NoCaching/Line.cs

+2-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22
{
33
public class Line
44
{
5-
public Point End;
6-
public Point Start;
7-
8-
public Line()
9-
{
10-
}
5+
public readonly Point End;
6+
public readonly Point Start;
117

128
public Line(Point start, Point end)
139
{

Adapter/NoCaching/LineToPointAdapter.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ namespace Adapter.NoCaching
55
{
66
public class LineToPointAdapter : Collection<Point>
77
{
8-
private static int count;
8+
private static int _count;
99

1010
public LineToPointAdapter(Line line)
1111
{
1212
Console
1313
.WriteLine(
14-
$"{++count}: Generating points for line [{line.Start.X},{line.Start.Y}]-[{line.End.X},{line.End.Y}] (no caching)");
14+
$"{++_count}: Generating points for line [{line.Start.X},{line.Start.Y}]-[{line.End.X},{line.End.Y}] (no caching)");
1515

1616
var left = Math.Min(line.Start.X, line.End.X);
1717
var right = Math.Max(line.Start.X, line.End.X);

Adapter/WithCaching/Demo.cs

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using MoreLinq;
45

56
namespace Adapter.WithCaching
67
{
7-
public class Demo
8+
public static class Demo
89
{
9-
private static readonly List<VectorObject> vectorObjects = new List<VectorObject>
10+
private static readonly List<VectorObject> VectorObjects = new()
1011
{
1112
new VectorRectangle(1, 1, 10, 10),
1213
new VectorRectangle(3, 3, 6, 6)
1314
};
1415

1516
// the interface we have
16-
public static void DrawPoint(Point p)
17+
private static void DrawPoint(Point p)
1718
{
1819
Console.Write(".");
1920
}
2021

21-
private static void Main(string[] args)
22-
{
23-
Draw();
24-
Draw();
25-
}
22+
// private static void Main(string[] args)
23+
// {
24+
// Draw();
25+
// Draw();
26+
// }
2627

2728
private static void Draw()
2829
{
29-
foreach (var vo in vectorObjects)
30-
foreach (var line in vo)
31-
{
32-
var adapter = new LineToPointAdapter(line);
30+
foreach (var adapter in from vo in VectorObjects from line in vo select new LineToPointAdapter(line))
3331
adapter.ForEach(DrawPoint);
34-
}
3532
}
3633
}
3734
}

Adapter/WithCaching/Line.cs

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
{
33
public class Line
44
{
5-
public Point End;
6-
public Point Start;
5+
public readonly Point End;
6+
public readonly Point Start;
77

88
public Line(Point start, Point end)
99
{
1010
Start = start;
1111
End = end;
1212
}
1313

14-
protected bool Equals(Line other)
14+
private bool Equals(Line other)
1515
{
1616
return Equals(Start, other.Start) && Equals(End, other.End);
1717
}
@@ -20,8 +20,7 @@ public override bool Equals(object obj)
2020
{
2121
if (ReferenceEquals(null, obj)) return false;
2222
if (ReferenceEquals(this, obj)) return true;
23-
if (obj.GetType() != GetType()) return false;
24-
return Equals((Line) obj);
23+
return obj.GetType() == GetType() && Equals((Line) obj);
2524
}
2625

2726
public override int GetHashCode()

Adapter/WithCaching/LineToPointAdapter.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ namespace Adapter.WithCaching
66
{
77
public class LineToPointAdapter : IEnumerable<Point>
88
{
9-
private static int count;
10-
private static readonly Dictionary<int, List<Point>> cache = new Dictionary<int, List<Point>>();
9+
private static int _count;
10+
private static readonly Dictionary<int, List<Point>> Cache = new();
1111
private readonly int hash;
1212

1313
public LineToPointAdapter(Line line)
1414
{
1515
hash = line.GetHashCode();
16-
if (cache.ContainsKey(hash)) return; // we already have it
16+
if (Cache.ContainsKey(hash)) return; // we already have it
1717

1818
Console
1919
.WriteLine(
20-
$"{++count}: Generating points for line [{line.Start.X},{line.Start.Y}]-[{line.End.X},{line.End.Y}] (with caching)");
20+
$"{++_count}: Generating points for line [{line.Start.X},{line.Start.Y}]-[{line.End.X},{line.End.Y}] (with caching)");
2121
// ^^^^
2222

2323
var points = new List<Point>();
@@ -36,12 +36,12 @@ public LineToPointAdapter(Line line)
3636
for (var x = left; x <= right; ++x)
3737
points.Add(new Point(x, top));
3838

39-
cache.Add(hash, points);
39+
Cache.Add(hash, points);
4040
}
4141

4242
public IEnumerator<Point> GetEnumerator()
4343
{
44-
return cache[hash].GetEnumerator();
44+
return Cache[hash].GetEnumerator();
4545
}
4646

4747
IEnumerator IEnumerable.GetEnumerator()

Adapter/WithCaching/Point.cs

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
{
33
public class Point
44
{
5-
public int X;
6-
public int Y;
5+
public readonly int X;
6+
public readonly int Y;
77

88
public Point(int x, int y)
99
{
1010
X = x;
1111
Y = y;
1212
}
1313

14-
protected bool Equals(Point other)
14+
private bool Equals(Point other)
1515
{
1616
return X == other.X && Y == other.Y;
1717
}
@@ -20,8 +20,7 @@ public override bool Equals(object obj)
2020
{
2121
if (ReferenceEquals(null, obj)) return false;
2222
if (ReferenceEquals(this, obj)) return true;
23-
if (obj.GetType() != GetType()) return false;
24-
return Equals((Point) obj);
23+
return obj.GetType() == GetType() && Equals((Point) obj);
2524
}
2625

2726
public override int GetHashCode()

Adapter/obj/Adapter.csproj.nuget.cache

-5
This file was deleted.

Adapter/obj/Adapter.csproj.nuget.dgspec.json

+26-21
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
11
{
22
"format": 1,
33
"restore": {
4-
"C:\\Pessoal\\design-patterns\\Adapter\\Adapter.csproj": {}
4+
"/home/jcmdsbr/workspaces/github/aspnetcore-design-patterns/Adapter/Adapter.csproj": {}
55
},
66
"projects": {
7-
"C:\\Pessoal\\design-patterns\\Adapter\\Adapter.csproj": {
7+
"/home/jcmdsbr/workspaces/github/aspnetcore-design-patterns/Adapter/Adapter.csproj": {
88
"version": "1.0.0",
99
"restore": {
10-
"projectUniqueName": "C:\\Pessoal\\design-patterns\\Adapter\\Adapter.csproj",
10+
"projectUniqueName": "/home/jcmdsbr/workspaces/github/aspnetcore-design-patterns/Adapter/Adapter.csproj",
1111
"projectName": "Adapter",
12-
"projectPath": "C:\\Pessoal\\design-patterns\\Adapter\\Adapter.csproj",
13-
"packagesPath": "C:\\Users\\jean.moreira\\.nuget\\packages\\",
14-
"outputPath": "C:\\Pessoal\\design-patterns\\Adapter\\obj\\",
12+
"projectPath": "/home/jcmdsbr/workspaces/github/aspnetcore-design-patterns/Adapter/Adapter.csproj",
13+
"packagesPath": "/home/jcmdsbr/.nuget/packages/",
14+
"outputPath": "/home/jcmdsbr/workspaces/github/aspnetcore-design-patterns/Adapter/obj/",
1515
"projectStyle": "PackageReference",
1616
"fallbackFolders": [
17-
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
17+
"/usr/share/dotnet/sdk/NuGetFallbackFolder"
1818
],
1919
"configFilePaths": [
20-
"C:\\Users\\jean.moreira\\AppData\\Roaming\\NuGet\\NuGet.Config",
21-
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
20+
"/home/jcmdsbr/.nuget/NuGet/NuGet.Config"
2221
],
2322
"originalTargetFrameworks": [
24-
"netcoreapp2.2"
23+
"net5.0"
2524
],
2625
"sources": {
27-
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
2826
"https://api.nuget.org/v3/index.json": {}
2927
},
3028
"frameworks": {
31-
"netcoreapp2.2": {
29+
"net5.0": {
30+
"targetAlias": "net5.0",
3231
"projectReferences": {}
3332
}
3433
},
@@ -39,24 +38,30 @@
3938
}
4039
},
4140
"frameworks": {
42-
"netcoreapp2.2": {
41+
"net5.0": {
42+
"targetAlias": "net5.0",
4343
"dependencies": {
44-
"Microsoft.NETCore.App": {
45-
"suppressParent": "All",
46-
"target": "Package",
47-
"version": "[2.2.0, )",
48-
"autoReferenced": true
49-
},
5044
"morelinq": {
5145
"target": "Package",
5246
"version": "[3.1.1, )"
5347
}
5448
},
5549
"imports": [
56-
"net461"
50+
"net461",
51+
"net462",
52+
"net47",
53+
"net471",
54+
"net472",
55+
"net48"
5756
],
5857
"assetTargetFallback": true,
59-
"warn": true
58+
"warn": true,
59+
"frameworkReferences": {
60+
"Microsoft.NETCore.App": {
61+
"privateAssets": "all"
62+
}
63+
},
64+
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/5.0.201/RuntimeIdentifierGraph.json"
6065
}
6166
}
6267
}

Adapter/obj/Adapter.csproj.nuget.g.props

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
44
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
55
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
6-
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">c:\Pessoal\design-patterns\Adapter\obj\project.assets.json</ProjectAssetsFile>
7-
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
8-
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\jean.moreira\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder</NuGetPackageFolders>
6+
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
7+
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/home/jcmdsbr/.nuget/packages/</NuGetPackageRoot>
8+
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/jcmdsbr/.nuget/packages/;/usr/share/dotnet/sdk/NuGetFallbackFolder</NuGetPackageFolders>
99
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
10-
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">4.9.4</NuGetToolVersion>
10+
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.8.0</NuGetToolVersion>
1111
</PropertyGroup>
12+
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
13+
<SourceRoot Include="$([MSBuild]::EnsureTrailingSlash($(NuGetPackageFolders)))" />
14+
</ItemGroup>
1215
<PropertyGroup>
1316
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
1417
</PropertyGroup>
15-
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
16-
<Import Project="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\build\netcoreapp2.2\Microsoft.NETCore.App.props" Condition="Exists('C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\build\netcoreapp2.2\Microsoft.NETCore.App.props')" />
17-
</ImportGroup>
1818
</Project>

Adapter/obj/Adapter.csproj.nuget.g.targets

-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,4 @@
33
<PropertyGroup>
44
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
55
</PropertyGroup>
6-
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
7-
<Import Project="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\netstandard.library\2.0.3\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('C:\Program Files\dotnet\sdk\NuGetFallbackFolder\netstandard.library\2.0.3\build\netstandard2.0\NETStandard.Library.targets')" />
8-
<Import Project="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\build\netcoreapp2.2\Microsoft.NETCore.App.targets" Condition="Exists('C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\build\netcoreapp2.2\Microsoft.NETCore.App.targets')" />
9-
</ImportGroup>
106
</Project>
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
f1914d7390cbe0086c5683197596e35be317bbd3
1+
6169ea65db75a6142951471928bf36986e1baeef
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
C:\Pessoal\design-patterns\Adapter\bin\Debug\netcoreapp2.2\Adapter.deps.json
2-
C:\Pessoal\design-patterns\Adapter\bin\Debug\netcoreapp2.2\Adapter.runtimeconfig.json
3-
C:\Pessoal\design-patterns\Adapter\bin\Debug\netcoreapp2.2\Adapter.runtimeconfig.dev.json
4-
C:\Pessoal\design-patterns\Adapter\bin\Debug\netcoreapp2.2\Adapter.dll
5-
C:\Pessoal\design-patterns\Adapter\bin\Debug\netcoreapp2.2\Adapter.pdb
6-
C:\Pessoal\design-patterns\Adapter\obj\Debug\netcoreapp2.2\Adapter.csprojAssemblyReference.cache
7-
C:\Pessoal\design-patterns\Adapter\obj\Debug\netcoreapp2.2\Adapter.csproj.CoreCompileInputs.cache
8-
C:\Pessoal\design-patterns\Adapter\obj\Debug\netcoreapp2.2\Adapter.AssemblyInfoInputs.cache
9-
C:\Pessoal\design-patterns\Adapter\obj\Debug\netcoreapp2.2\Adapter.AssemblyInfo.cs
10-
C:\Pessoal\design-patterns\Adapter\obj\Debug\netcoreapp2.2\Adapter.dll
11-
C:\Pessoal\design-patterns\Adapter\obj\Debug\netcoreapp2.2\Adapter.pdb
1+
C:/Pessoal/design-patterns/Adapter/bin/Debug/netcoreapp2.2/Adapter.deps.json
2+
C:/Pessoal/design-patterns/Adapter/bin/Debug/netcoreapp2.2/Adapter.runtimeconfig.json
3+
C:/Pessoal/design-patterns/Adapter/bin/Debug/netcoreapp2.2/Adapter.runtimeconfig.dev.json
4+
C:/Pessoal/design-patterns/Adapter/bin/Debug/netcoreapp2.2/Adapter.dll
5+
C:/Pessoal/design-patterns/Adapter/bin/Debug/netcoreapp2.2/Adapter.pdb
6+
C:/Pessoal/design-patterns/Adapter/obj/Debug/netcoreapp2.2/Adapter.csprojAssemblyReference.cache
7+
C:/Pessoal/design-patterns/Adapter/obj/Debug/netcoreapp2.2/Adapter.csproj.CoreCompileInputs.cache
8+
C:/Pessoal/design-patterns/Adapter/obj/Debug/netcoreapp2.2/Adapter.AssemblyInfoInputs.cache
9+
C:/Pessoal/design-patterns/Adapter/obj/Debug/netcoreapp2.2/Adapter.AssemblyInfo.cs
10+
C:/Pessoal/design-patterns/Adapter/obj/Debug/netcoreapp2.2/Adapter.dll
11+
C:/Pessoal/design-patterns/Adapter/obj/Debug/netcoreapp2.2/Adapter.pdb
12+
/home/jcmdsbr/workspaces/github/aspnetcore-design-patterns/Adapter/obj/Debug/netcoreapp2.2/Adapter.csprojAssemblyReference.cache
13+
/home/jcmdsbr/workspaces/github/aspnetcore-design-patterns/Adapter/obj/Debug/netcoreapp2.2/Adapter.AssemblyInfoInputs.cache
14+
/home/jcmdsbr/workspaces/github/aspnetcore-design-patterns/Adapter/obj/Debug/netcoreapp2.2/Adapter.AssemblyInfo.cs
15+
/home/jcmdsbr/workspaces/github/aspnetcore-design-patterns/Adapter/obj/Debug/netcoreapp2.2/Adapter.csproj.CoreCompileInputs.cache
16+
/home/jcmdsbr/workspaces/github/aspnetcore-design-patterns/Adapter/obj/Debug/netcoreapp2.2/Adapter.dll
17+
/home/jcmdsbr/workspaces/github/aspnetcore-design-patterns/Adapter/obj/Debug/netcoreapp2.2/Adapter.pdb
Binary file not shown.

0 commit comments

Comments
 (0)