Skip to content

Commit

Permalink
Introduced Pure Resolvers and Resolver Inlining (ChilliCream#3638)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib authored May 6, 2021
1 parent c59403c commit 5b27da4
Show file tree
Hide file tree
Showing 374 changed files with 27,401 additions and 2,751 deletions.
4 changes: 2 additions & 2 deletions .build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
AzurePipelinesImage.UbuntuLatest,
InvokedTargets = new[] { nameof(Sonar) },
PullRequestsAutoCancel = true,
PullRequestsBranchesInclude = new [] { "master" },
AutoGenerate = false)]
PullRequestsBranchesInclude = new[] { "master" },
AutoGenerate = false)]
[GitHubActions(
"sonar-pr-hotchocolate",
GitHubActionsImage.UbuntuLatest,
Expand Down
6 changes: 6 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
"commands": [
"nuke"
]
},
"boost.tool": {
"version": "0.2.2",
"commands": [
"boo"
]
}
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,4 @@ src/All.sln

# asp .net core
appsettings.user.json
conferences.db
104 changes: 104 additions & 0 deletions API-Baselines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# API Baselines

This document contains information regarding API baseline files and how to work with them.

## Files

Each project contains two files tracking the public API surface of this project.

### PublicAPI.Shipped.txt

This file contains APIs that were released in the last major version.

This file should only be modified after a major release by the maintainers and should never be modified otherwise. There is a [script](#scripts) to perform this automatically.

### PublicAPI.Unshipped.txt

This file contains API changes since the last major version.

## Scenarios

There are three types of public API changes that need to be documented.

### New APIs

A new entry needs to be added to the `PublicAPI.Unshipped.txt` file for a new API. For example:

```
#nullable enable
Microsoft.AspNetCore.Builder.NewApplicationBuilder.New() -> Microsoft.AspNetCore.Builder.IApplicationBuilder!
```

Your IDE should warn you about this case and prompt you to add the new API to `PublicAPI.Unshipped.txt`. It will also be displayed as a warning in the build output.

> Note: Currently not every IDE supports Code-Fixes provided by a Roslyn Analyzer. Visual Studio Code for example does not at the moment - Visual Studio 2019 does.
### Removed APIs

A new entry needs to be added to the `PublicAPI.Unshipped.txt` file for a removed API. For example:

```
#nullable enable
*REMOVED*Microsoft.Builder.OldApplicationBuilder.New() -> Microsoft.AspNetCore.Builder.IApplicationBuilder!
```

This change needs to be done by hand. Copy the relevant line from `PublicAPI.Shipped.txt` into `PublicAPI.Unshipped.txt` and place `*REMOVED*` in front of it.

### Updated APIs

Two new entries need to be added to the `PublicAPI.Unshipped.txt` file for an updated API. One to remove the old API and one for the new API. For example:

```
#nullable enable
*REMOVED*Microsoft.AspNetCore.DataProtection.Infrastructure.IApplicationDiscriminator.Discriminator.get -> string!
Microsoft.AspNetCore.DataProtection.Infrastructure.IApplicationDiscriminator.Discriminator.get -> string?
```

The removed case needs to be handled by hand as explained [here](#removed-apis).

## Ignoring projects

Projects ending in `.Tests` or `.Resources` are ignored per default.

If you need to manually ignore a project, include the following in its `.csproj` file:

```xml
<PropertyGroup>
<AddPublicApiAnalyzers>false</AddPublicApiAnalyzers>
</PropertyGroup>
```

## New projects

The two text files mentioned above need to be added to each new project.

There is a template file called `PublicAPI.empty.txt` in the `scripts` directory that can be copied over into a new project.

```sh
cp scripts/PublicAPI.empty.txt src/<new-project-folder>/PublicAPI.Shipped.txt
cp scripts/PublicAPI.empty.txt src/<new-project-folder>/PublicAPI.Unshipped.txt
```

## Scripts

There are three scripts to help you manage the `PublicAPI.*.txt` files. They can be found [here](./scripts).

### mark-api-shipped.ps1

This transfers all changes in the `PublicAPI.Unshipped.txt` to the `PublicAPI.Shipped.txt` files.

It also takes care of removing lines marked with `*REMOVE*` (removals of APIs).

### display-unshipped-api.ps1

This will output the contents of all `PublicAPI.Unshipped.txt` files throughout the project.

### diff-shipped-api.ps1

This shows all changes of `PublicAPI.Shipped.txt` files between git refs. Tags, commit hashes and branch names are supported.

Example:

```sh
diff-shipped-api.ps1 -from 11.0.0 -to 12.0.0
```
File renamed without changes.
4 changes: 4 additions & 0 deletions COMMUNITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Various libraries, packages, etc. that developers can add to their own project a

- [AutoGuru.HotChocolate.PolymorphicIds](https://github.com/autoguru-au/hotchocolate-polymorphic-ids) - Polymorphic Relay IDs for HotChocolate

## Types

- [HotChocolate.Types.NodaTime](https://github.com/shoooe/hotchocolate-nodatime) - Adds support for [NodaTime](https://github.com/nodatime/nodatime) types in Hot Chocolate.

### Validation

- [AppAny.HotChocolate.FluentValidation](https://github.com/appany/AppAny.HotChocolate.FluentValidation) - Input field HotChocolate + FluentValidation integration
Expand Down
61 changes: 61 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# How to contribute

One of the easiest ways to contribute is to participate in discussions on GitHub issues. You can also contribute by submitting pull requests with code changes.

## General feedback and discussions?

Start a discussion on the [repository issue tracker](https://github.com/ChilliCream/hotchocolate/issues) or [join us on slack](https://bit.ly/join-chillicream-slack).

## Bugs and feature requests?

Before reporting a new issue, try to find an existing issue if one already exists. If it already exists, upvote (👍) it. Also consider adding a comment with your unique scenarios and requirements related to that issue.

If you can't find one, you can file a new issue by choosing the appropriate template [here](https://github.com/ChilliCream/hotchocolate/issues/new/choose).

## How to submit a pull request

We are always happy to see pull requests from community members both for bug fixes as well as new features.

### Finding an issue to work on

We have marked issues which are good candidates for first-time contributors, in case you are not already set on working on a specific issue.

- ["Good first issue" issues](https://github.com/ChilliCream/hotchocolate/labels/%F0%9F%99%8B%20good%20first%20issue) - we think these are a great for newcomers.
- ["Help wanted" issues](https://github.com/ChilliCream/hotchocolate/labels/%F0%9F%99%8B%20help%20wanted) - these issues are up for grabs.

### Before writing code

Before you spend time writing code, make sure of the following things:

- You have commented on the related issue to let others know you are working on it
- You have laid out your solution on a high level and received approval from the maintainers, if you are tackling a bigger change

After this you can fork our repository to implement your changes. If you are unfamiliar with forking, be sure to read [this guide](https://guides.github.com/activities/forking/) first.

### Before submitting a pull request

Before submitting a pull request containing your changes, make sure that it checks the following requirements:

- You add test coverage following existing patterns within the codebase
- Your code matches the existing syntax conventions within the codebase
- You document any changes to the public API surface ([Learn more](./API-Baselines.md))
- Your pull request is small, focused, and avoids making unrelated changes

If your pull request contains any of the below, it's less likely to be merged.

- Changes that break backward compatibility
- Changes that are only wanted by one person/company
- Changes that add entirely new feature areas without prior agreement
- Changes that are mostly about refactoring existing code or code style

### Submitting a pull request

Follow [this guide](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) to submit your pull request. Be sure to mark it as draft if it is in an early stage.

### During pull request review

Core contributors will review your pull request and provide feedback.

## Code of conduct

See [CODE-OF-CONDUCT.md](./CODE-OF-CONDUCT.md)
31 changes: 0 additions & 31 deletions CONTRIBUTION.md

This file was deleted.

1 change: 1 addition & 0 deletions scripts/PublicAPI.empty.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable
19 changes: 19 additions & 0 deletions scripts/diff-shipped-api.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[CmdletBinding(PositionalBinding=$false)]
param (
[string]$from,
[string]$to = "main"
)

Set-StrictMode -version 2.0
$ErrorActionPreference = "Stop"

try {
Write-Host "Diffing '$from' to '$to'..."

git --no-pager diff --minimal -U0 --word-diff "$from" "$to" -- "../src/**/PublicAPI.Shipped.txt"
}
catch {
Write-Host $_
Write-Host $_.Exception
exit 1
}
35 changes: 35 additions & 0 deletions scripts/display-unshipped-api.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[CmdletBinding(PositionalBinding = $false)]
param ()

Set-StrictMode -version 2.0
$ErrorActionPreference = "Stop"

function ShowUnshipped([string]$file, [string]$src_dir) {
[string[]]$unshipped = Get-Content $file

if ([string]::IsNullOrWhiteSpace($unshipped)) {
return
}

$dir = (Split-Path -parent $file) -replace [regex]::escape($src_dir + [IO.Path]::DirectorySeparatorChar), ""
Write-Host -Foreground green "## ${dir}"

foreach ($item in $unshipped) {
if ($item.Length -gt 0) {
Write-Host "$item"
}
}
}

try {
$src_dir = Resolve-Path -Path "../src"

foreach ($file in Get-ChildItem -Path "$src_dir" -Recurse -Include "PublicApi.Unshipped.txt") {
ShowUnshipped $file $src_dir
}
}
catch {
Write-Host $_
Write-Host $_.Exception
exit 1
}
51 changes: 51 additions & 0 deletions scripts/mark-api-shipped.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[CmdletBinding(PositionalBinding = $false)]
param ()

Set-StrictMode -version 2.0
$ErrorActionPreference = "Stop"

function MarkShipped([string]$dir) {
$shippedFilePath = Join-Path $dir "PublicAPI.Shipped.txt"
[string[]]$shipped = Get-Content $shippedFilePath
if ($null -eq $shipped) {
$shipped = @()
}

$unshippedFilePath = Join-Path $dir "PublicAPI.Unshipped.txt"
[string[]]$unshipped = Get-Content $unshippedFilePath | Where-Object { $_.trim() -ne "" }
if ($null -eq $unshipped -or $unshipped.Length -lt 1) {
return
}

$removed = @()
$removedPrefix = "*REMOVED*";

Write-Host "Processing $dir"

foreach ($item in $unshipped) {
if ($item.Length -gt 0) {
if ($item.StartsWith($removedPrefix)) {
$item = $item.Substring($removedPrefix.Length)
$removed += $item
}
else {
$shipped += $item
}
}
}

$shipped | Sort-Object -Stable -Unique | Where-Object { -not $removed.Contains($_) } | Out-File $shippedFilePath -Encoding Ascii
"" | Out-File $unshippedFilePath -Encoding Ascii
}

try {
foreach ($file in Get-ChildItem -Path "../src" -Recurse -Include "PublicApi.Shipped.txt") {
$dir = Split-Path -parent $file
MarkShipped $dir
}
}
catch {
Write-Host $_
Write-Host $_.Exception
exit 1
}
Loading

0 comments on commit 5b27da4

Please sign in to comment.