Skip to content

Commit 286eea7

Browse files
author
Bart Koelman
authored
Merge pull request #744 from bart-degreed/projects-cleanup
Projects cleanup
2 parents 736c710 + 29ac0de commit 286eea7

Some content is hidden

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

61 files changed

+631
-606
lines changed

Build.ps1

+2-16
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,7 @@ CheckLastExitCode
2727
dotnet build -c Release
2828
CheckLastExitCode
2929

30-
# Workaround: running 'dotnet test -c Release' fails for yet unknown reasons on AppVeyor, so we run tests one by one.
31-
32-
dotnet test ./test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj -c Release --no-build
33-
CheckLastExitCode
34-
35-
dotnet test ./test/DiscoveryTests/DiscoveryTests.csproj -c Release --no-build
36-
CheckLastExitCode
37-
38-
dotnet test ./test/IntegrationTests/IntegrationTests.csproj -c Release --no-build
39-
CheckLastExitCode
40-
41-
dotnet test ./test/UnitTests/UnitTests.csproj -c Release --no-build
42-
CheckLastExitCode
43-
44-
dotnet test ./test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj -c Release --no-build
30+
dotnet test -c Release --no-build
4531
CheckLastExitCode
4632

4733
Write-Output "APPVEYOR_REPO_TAG: $env:APPVEYOR_REPO_TAG"
@@ -62,7 +48,7 @@ If($env:APPVEYOR_REPO_TAG -eq $true) {
6248
}
6349
}
6450
Else {
65-
Write-Output "VERSION-SUFFIX: alpha1-$revision"
51+
Write-Output "VERSION-SUFFIX: alpha5-$revision"
6652
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=alpha1-$revision"
6753
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=alpha1-$revision --include-symbols
6854
CheckLastExitCode

appveyor.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@ version: '{build}'
22
os: Visual Studio 2019
33

44
environment:
5-
POSTGRES_PORT: tcp://localhost:5432
6-
POSTGRES_ENV_POSTGRES_USER: postgres
7-
POSTGRES_ENV_POSTGRES_PASSWORD: Password12!
8-
POSTGRES_ENV_POSTGRES_DB: JsonApiDotNetCoreExample
95
PGUSER: postgres
106
PGPASSWORD: Password12!
11-
Data:DefaultConnection: "Host=localhost;Port=5432;Database=JsonApiDotNetCoreExample;User ID=postgres;Password=Password12!"
127
ACCESS_TOKEN:
138
secure: g1T332Uarmdgtkftchpafa8tDP/7eM4O0BD6iu1wu+zR224IyH5R8pb4sTChr4Ia
149

@@ -63,10 +58,9 @@ init:
6358
- SET PATH=C:\Program Files\PostgreSQL\9.6\bin\;%PATH%
6459

6560
services:
66-
- postgresql
61+
- postgresql96
6762

6863
build_script:
69-
- ps: createdb JsonApiDotNetCoreExample
7064
- ps: dotnet --version
7165
- ps: .\Build.ps1
7266

src/Examples/GettingStarted/Controllers/ArticlesController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using JsonApiDotNetCore.Services;
55
using Microsoft.Extensions.Logging;
66

7-
namespace GettingStarted
7+
namespace GettingStarted.Controllers
88
{
99
public sealed class ArticlesController : JsonApiController<Article>
1010
{

src/Examples/GettingStarted/Controllers/PeopleController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using JsonApiDotNetCore.Services;
55
using Microsoft.Extensions.Logging;
66

7-
namespace GettingStarted
7+
namespace GettingStarted.Controllers
88
{
99
public sealed class PeopleController : JsonApiController<Person>
1010
{
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
using GettingStarted.Models;
2-
using GettingStarted.ResourceDefinitionExample;
32
using Microsoft.EntityFrameworkCore;
43

5-
namespace GettingStarted
4+
namespace GettingStarted.Data
65
{
76
public class SampleDbContext : DbContext
87
{
9-
public SampleDbContext(DbContextOptions<SampleDbContext> options) : base(options) { }
108
public DbSet<Article> Articles { get; set; }
11-
public DbSet<Person> People { get; set; }
12-
public DbSet<Model> Models { get; set; }
9+
10+
public SampleDbContext(DbContextOptions<SampleDbContext> options)
11+
: base(options)
12+
{
13+
}
14+
15+
protected override void OnModelCreating(ModelBuilder modelBuilder)
16+
{
17+
modelBuilder.Entity<Person>();
18+
}
1319
}
14-
}
20+
}

src/Examples/GettingStarted/Models/Article.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ public sealed class Article : Identifiable
66
{
77
[Attr]
88
public string Title { get; set; }
9+
910
[HasOne]
1011
public Person Author { get; set; }
11-
public int AuthorId { get; set; }
1212
}
1313
}

src/Examples/GettingStarted/Models/Person.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ namespace GettingStarted.Models
55
{
66
public sealed class Person : Identifiable
77
{
8-
[Attr]
8+
[Attr]
99
public string Name { get; set; }
1010

11-
[HasMany]
11+
[HasMany]
1212
public ICollection<Article> Articles { get; set; }
1313
}
1414
}
+8-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
using Microsoft.AspNetCore;
21
using Microsoft.AspNetCore.Hosting;
2+
using Microsoft.Extensions.Hosting;
33

44
namespace GettingStarted
55
{
66
public class Program
77
{
88
public static void Main(string[] args)
99
{
10-
CreateWebHostBuilder(args).Build().Run();
10+
CreateHostBuilder(args).Build().Run();
1111
}
1212

13-
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
14-
WebHost.CreateDefaultBuilder(args)
15-
.UseStartup<Startup>()
16-
.UseUrls("http://localhost:5001");
13+
public static IHostBuilder CreateHostBuilder(string[] args) =>
14+
Host.CreateDefaultBuilder(args)
15+
.ConfigureWebHostDefaults(webBuilder =>
16+
{
17+
webBuilder.UseStartup<Startup>();
18+
});
1719
}
1820
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
11
{
2-
"profiles": {
3-
"GettingStarted": {
4-
"commandName": "Project",
5-
"launchBrowser": true,
6-
"environmentVariables": {
7-
"ASPNETCORE_ENVIRONMENT": "Development"
8-
},
9-
"applicationUrl": "https://localhost:5001;http://localhost:5000"
2+
"$schema": "http://json.schemastore.org/launchsettings.json",
3+
"iisSettings": {
4+
"windowsAuthentication": false,
5+
"anonymousAuthentication": true,
6+
"iisExpress": {
7+
"applicationUrl": "http://localhost:14141",
8+
"sslPort": 44344
9+
}
10+
},
11+
"profiles": {
12+
"IIS Express": {
13+
"commandName": "IISExpress",
14+
"launchBrowser": false,
15+
"launchUrl": "api/people",
16+
"environmentVariables": {
17+
"ASPNETCORE_ENVIRONMENT": "Development"
18+
}
19+
},
20+
"Kestrel": {
21+
"commandName": "Project",
22+
"launchBrowser": false,
23+
"launchUrl": "api/people",
24+
"applicationUrl": "https://localhost:44344;http://localhost:14141",
25+
"environmentVariables": {
26+
"ASPNETCORE_ENVIRONMENT": "Development"
27+
}
28+
}
1029
}
11-
}
12-
}
30+
}

src/Examples/GettingStarted/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
`dotnet run` to run the project
66

77
You can verify the project is running by checking this endpoint:
8-
`localhost:5001/api/sample-model`
8+
`localhost:14141/api/people`
99

1010
For further documentation and implementation of a JsonApiDotnetCore Application see the documentation or GitHub page:
1111

1212
Repository: https://github.com/json-api-dotnet/JsonApiDotNetCore
1313

14-
Documentation: https://json-api-dotnet.github.io/
14+
Documentation: https://json-api-dotnet.github.io/
+33-11
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,53 @@
1+
using GettingStarted.Data;
2+
using GettingStarted.Models;
3+
using JsonApiDotNetCore;
14
using Microsoft.AspNetCore.Builder;
2-
using Microsoft.Extensions.DependencyInjection;
35
using Microsoft.EntityFrameworkCore;
4-
using JsonApiDotNetCore;
6+
using Microsoft.Extensions.DependencyInjection;
57

68
namespace GettingStarted
79
{
810
public sealed class Startup
911
{
12+
// This method gets called by the runtime. Use this method to add services to the container.
1013
public void ConfigureServices(IServiceCollection services)
1114
{
12-
services.AddDbContext<SampleDbContext>(options =>
13-
{
14-
options.UseSqlite("Data Source=sample.db");
15-
});
15+
services.AddDbContext<SampleDbContext>(
16+
options => options.UseSqlite("Data Source=sample.db"));
1617

17-
var mvcBuilder = services.AddMvcCore();
18-
services.AddJsonApi(
19-
options => options.Namespace = "api",
20-
discover => discover.AddCurrentAssembly(), mvcBuilder: mvcBuilder);
18+
services.AddJsonApi<SampleDbContext>(
19+
options => options.Namespace = "api");
2120
}
2221

22+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
2323
public void Configure(IApplicationBuilder app, SampleDbContext context)
2424
{
25-
// indices need to be reset
2625
context.Database.EnsureDeleted();
2726
context.Database.EnsureCreated();
27+
CreateSampleData(context);
28+
2829
app.UseJsonApi();
2930
}
31+
32+
private static void CreateSampleData(SampleDbContext context)
33+
{
34+
context.Articles.AddRange(new Article
35+
{
36+
Title = "What's new in JsonApiDotNetCore",
37+
Author = new Person
38+
{
39+
Name = "John Doe"
40+
}
41+
}, new Article
42+
{
43+
Title = ".NET Core Best Practices",
44+
Author = new Person
45+
{
46+
Name = "Microsoft"
47+
}
48+
});
49+
50+
context.SaveChanges();
51+
}
3052
}
3153
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Warning",
5+
"Microsoft": "Warning",
6+
"Microsoft.EntityFrameworkCore.Database.Command": "Information"
7+
}
8+
},
9+
"AllowedHosts": "*"
10+
}

src/Examples/GettingStarted/ResourceDefinitionExample/ModelsController.cs renamed to src/Examples/JsonApiDotNetCoreExample/Controllers/ModelsController.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
using JsonApiDotNetCore.Configuration;
22
using JsonApiDotNetCore.Controllers;
33
using JsonApiDotNetCore.Services;
4+
using JsonApiDotNetCoreExample.Models;
45
using Microsoft.Extensions.Logging;
56

6-
namespace GettingStarted.ResourceDefinitionExample
7+
namespace JsonApiDotNetCoreExample.Controllers
78
{
89
public sealed class ModelsController : JsonApiController<Model>
910
{

src/Examples/JsonApiDotNetCoreExample/Resources/ArticleResource.cs renamed to src/Examples/JsonApiDotNetCoreExample/Definitions/ArticleDefinition.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
using System.Linq;
33
using System.Net;
44
using JsonApiDotNetCore.Exceptions;
5-
using JsonApiDotNetCore.Models;
65
using JsonApiDotNetCore.Hooks;
7-
using JsonApiDotNetCoreExample.Models;
86
using JsonApiDotNetCore.Internal.Contracts;
7+
using JsonApiDotNetCore.Models;
98
using JsonApiDotNetCore.Models.JsonApiDocuments;
9+
using JsonApiDotNetCoreExample.Models;
1010

11-
namespace JsonApiDotNetCoreExample.Resources
11+
namespace JsonApiDotNetCoreExample.Definitions
1212
{
13-
public class ArticleResource : ResourceDefinition<Article>
13+
public class ArticleDefinition : ResourceDefinition<Article>
1414
{
15-
public ArticleResource(IResourceGraph resourceGraph) : base(resourceGraph) { }
15+
public ArticleDefinition(IResourceGraph resourceGraph) : base(resourceGraph) { }
1616

1717
public override IEnumerable<Article> OnReturn(HashSet<Article> entities, ResourcePipeline pipeline)
1818
{

src/Examples/JsonApiDotNetCoreExample/Resources/LockableResource.cs renamed to src/Examples/JsonApiDotNetCoreExample/Definitions/LockableDefinition.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
using JsonApiDotNetCore.Models.JsonApiDocuments;
88
using JsonApiDotNetCoreExample.Models;
99

10-
namespace JsonApiDotNetCoreExample.Resources
10+
namespace JsonApiDotNetCoreExample.Definitions
1111
{
12-
public abstract class LockableResource<T> : ResourceDefinition<T> where T : class, IIsLockable, IIdentifiable
12+
public abstract class LockableDefinition<T> : ResourceDefinition<T> where T : class, IIsLockable, IIdentifiable
1313
{
14-
protected LockableResource(IResourceGraph resourceGraph) : base(resourceGraph) { }
14+
protected LockableDefinition(IResourceGraph resourceGraph) : base(resourceGraph) { }
1515

1616
protected void DisallowLocked(IEnumerable<T> entities)
1717
{

src/Examples/GettingStarted/ResourceDefinitionExample/ModelDefinition.cs renamed to src/Examples/JsonApiDotNetCoreExample/Definitions/ModelDefinition.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
using JsonApiDotNetCore.Internal.Contracts;
22
using JsonApiDotNetCore.Models;
3+
using JsonApiDotNetCoreExample.Models;
34

4-
namespace GettingStarted.ResourceDefinitionExample
5+
namespace JsonApiDotNetCoreExample.Definitions
56
{
67
public class ModelDefinition : ResourceDefinition<Model>
78
{

src/Examples/JsonApiDotNetCoreExample/Resources/PassportResource.cs renamed to src/Examples/JsonApiDotNetCoreExample/Definitions/PassportDefinition.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
using System.Linq;
33
using System.Net;
44
using JsonApiDotNetCore.Exceptions;
5-
using JsonApiDotNetCore.Models;
65
using JsonApiDotNetCore.Hooks;
7-
using JsonApiDotNetCoreExample.Models;
86
using JsonApiDotNetCore.Internal.Contracts;
7+
using JsonApiDotNetCore.Models;
98
using JsonApiDotNetCore.Models.JsonApiDocuments;
9+
using JsonApiDotNetCoreExample.Models;
1010

11-
namespace JsonApiDotNetCoreExample.Resources
11+
namespace JsonApiDotNetCoreExample.Definitions
1212
{
13-
public class PassportResource : ResourceDefinition<Passport>
13+
public class PassportDefinition : ResourceDefinition<Passport>
1414
{
15-
public PassportResource(IResourceGraph resourceGraph) : base(resourceGraph)
15+
public PassportDefinition(IResourceGraph resourceGraph) : base(resourceGraph)
1616
{
1717
}
1818

src/Examples/JsonApiDotNetCoreExample/Resources/PersonResource.cs renamed to src/Examples/JsonApiDotNetCoreExample/Definitions/PersonDefinition.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
using System.Collections.Generic;
22
using System.Linq;
33
using JsonApiDotNetCore.Hooks;
4-
using JsonApiDotNetCoreExample.Models;
54
using JsonApiDotNetCore.Internal.Contracts;
65
using JsonApiDotNetCore.Models;
6+
using JsonApiDotNetCoreExample.Models;
77

8-
namespace JsonApiDotNetCoreExample.Resources
8+
namespace JsonApiDotNetCoreExample.Definitions
99
{
10-
public class PersonResource : LockableResource<Person>, IHasMeta
10+
public class PersonDefinition : LockableDefinition<Person>, IHasMeta
1111
{
12-
public PersonResource(IResourceGraph resourceGraph) : base(resourceGraph) { }
12+
public PersonDefinition(IResourceGraph resourceGraph) : base(resourceGraph) { }
1313

1414
public override IEnumerable<string> BeforeUpdateRelationship(HashSet<string> ids, IRelationshipsDictionary<Person> entitiesByRelationship, ResourcePipeline pipeline)
1515
{

0 commit comments

Comments
 (0)