Skip to content

Commit

Permalink
Merge pull request #515 from SteveDunn/efcore-additions
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveDunn authored Nov 3, 2023
2 parents 9fb37ba + 59760ed commit 24b2f1a
Show file tree
Hide file tree
Showing 70,234 changed files with 3,066,495 additions and 11,733,402 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
12 changes: 12 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ jobs:
- name: Build and Test
run: ./Build.ps1
shell: pwsh
run-snapshots:
name: run-snapshots
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
dotnet-version: |
7.0.x
- name: Run Snapshots
run: ./RunSnapshots.ps1
shell: pwsh
macOS-latest:
name: macOS-latest
runs-on: macos-latest
Expand Down
55 changes: 8 additions & 47 deletions Build.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
param($verbosity = "minimal", [switch] $skiptests = $false, [switch] $resetSnapshots = $false) #quite|q, minimal|m, normal|n, detailed|d
param($verbosity = "minimal") #quite|q, minimal|m, normal|n, detailed|d

$artifacts = ".\artifacts"
$localPackages = ".\local-global-packages"
Expand All @@ -19,15 +19,6 @@ function Get999VersionWithUniquePatch()
return "999.9." + $patch;
}

function Remove-SnapshotsFolders($path) {
$folders = Get-ChildItem -Path $path -Directory -Filter "snapshots" -Recurse

foreach ($folder in $folders) {
Write-Host "Deleting folder: $($folder.FullName)"
Remove-Item -Path $folder.FullName -Recurse -Force
}
}

<#
.SYNOPSIS
Taken from psake https://github.com/psake/psake
Expand All @@ -51,25 +42,10 @@ function Exec
}
}

if ($env:GITHUB_ACTIONS -eq 'true' -and $resetSnapshots) {
throw "Cannot reset snapshots in GitHub, only locally."
}

if ($skiptests -and $resetSnapshots)
{
throw "Cannot skip tests if resetting snapshots, as the tests need to run."
}

WriteStage("Building release version of Vogen...")

if(Test-Path $artifacts) { Remove-Item $artifacts -Force -Recurse }

if($resetSnapshots)
{
WriteStage("Resetting snapshots...")
Remove-SnapshotsFolders(".\");
}

New-Item -Path $artifacts -ItemType Directory

New-Item -Path $localPackages -ItemType Directory -ErrorAction SilentlyContinue
Expand All @@ -84,30 +60,15 @@ exec { & dotnet clean Vogen.sln -c Release --verbosity $verbosity}
WriteStage("... restore ...")
exec { & dotnet restore Vogen.sln --no-cache --verbosity $verbosity }

if($resetSnapshots)
{
WriteStage("... resetting snapshots ...")
exec { & dotnet build Vogen.sln -c Release -p Thorough=true -p ResetSnapshots=true --no-restore --verbosity $verbosity}
}
else
{
exec { & dotnet build Vogen.sln -c Release -p Thorough=true --no-restore --verbosity $verbosity}
}

if($skiptests)
{
# run the analyzer and code generation tests
WriteStage("Skipping tests")
}
exec { & dotnet build Vogen.sln -c Release -p Thorough=true --no-restore --verbosity $verbosity}

if(!$skiptests)
{
# run the analyzer and code generation tests
WriteStage("Running analyzer and code generation tests...")
exec { & dotnet test Vogen.sln -c Release --no-build -l trx -l "GitHubActions;report-warnings=false" --verbosity $verbosity }
}
################################################################
# run the analyzer and code generation tests
WriteStage("Running analyzer tests...")
exec { & dotnet test tests/AnalyzerTests/AnalyzerTests.csproj -c Release --no-build -l trx -l "GitHubActions;report-warnings=false" --verbosity $verbosity }

WriteStage("Running unit tests...")
exec { & dotnet test tests/Vogen.Tests/Vogen.Tests.csproj -c Release --no-build -l trx -l "GitHubActions;report-warnings=false" --verbosity $verbosity }

# Run the end to end tests. The tests can't have project references to Vogen. This is because, in Visual Studio,
# it causes conflicts caused by the difference in runtime; VS uses netstandard2.0 to load and run the analyzers, but the
# test project uses a variety of runtimes. So, it uses NuGet to reference the Vogen analyzer. To do this, this script first
Expand Down
85 changes: 85 additions & 0 deletions RunSnapshots.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
param($verbosity = "minimal", [switch] $reset = $false) #quite|q, minimal|m, normal|n, detailed|d

$artifacts = ".\artifacts"
$localPackages = ".\local-global-packages"

function WriteStage([string]$message)
{
Write-Host "############################################" -ForegroundColor Cyan
Write-Host "**** " $message -ForegroundColor Cyan
Write-Host "############################################" -ForegroundColor Cyan
Write-Output ""
}

function Remove-SnapshotsFolders($path) {
$folders = Get-ChildItem -Path $path -Directory -Filter "snapshots" -Recurse

foreach ($folder in $folders) {
Write-Host "Deleting folder: $($folder.FullName)"
Remove-Item -Path $folder.FullName -Recurse -Force
}
}

<#
.SYNOPSIS
Taken from psake https://github.com/psake/psake
This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode
to see if an error occcured. If an error is detected then an exception is thrown.
This function allows you to run command-line programs without having to
explicitly check the $lastexitcode variable.
.EXAMPLE
exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN command-line client is installed"
#>
function Exec
{
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)][scriptblock]$cmd,
[Parameter(Position=1,Mandatory=0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd)
)
& $cmd
if ($lastexitcode -ne 0) {
throw ("Exec: " + $errorMessage)
}
}

WriteStage("Building release version of Vogen...")

if(Test-Path $artifacts) { Remove-Item $artifacts -Force -Recurse }

New-Item -Path $artifacts -ItemType Directory

New-Item -Path $localPackages -ItemType Directory -ErrorAction SilentlyContinue

if(Test-Path $localPackages) { Remove-Item $localPackages\vogen.* -Force -ErrorAction SilentlyContinue }

if($reset)
{
WriteStage("Resetting snapshots...")
Remove-SnapshotsFolders(".\");
}

WriteStage("Cleaning, restoring, and building release version of Vogen...")

WriteStage("... clean ...")
exec { & dotnet clean Vogen.sln -c Release --verbosity $verbosity}

WriteStage("... restore ...")
exec { & dotnet restore Vogen.sln --no-cache --verbosity $verbosity }

if($reset)
{
WriteStage("... resetting snapshots ...")
exec { & dotnet build Vogen.sln -c Release -p Thorough=true -p ResetSnapshots=true --no-restore --verbosity $verbosity}
}
else
{
exec { & dotnet build Vogen.sln -c Release -p Thorough=true --no-restore --verbosity $verbosity}
}

################################################################
WriteStage("Running snapshot tests...")
exec { & dotnet test tests/SnapshotTests/SnapshotTests.csproj -c Release --no-build -l trx -l "GitHubActions;report-warnings=false" --verbosity $verbosity }
################################################################

WriteStage("Done!")
1 change: 1 addition & 0 deletions Vogen.sln
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_files", "_files", "{72AF0E
.github\workflows\publish.yaml = .github\workflows\publish.yaml
README.md = README.md
test.ps1 = test.ps1
RunSnapshots.ps1 = RunSnapshots.ps1
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vogen.SharedTypes", "src\Vogen.SharedTypes\Vogen.SharedTypes.csproj", "{ACBCBC0B-430F-46A3-AD96-6AF28DBA7F9D}"
Expand Down
1 change: 1 addition & 0 deletions Vogen.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Beckham/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Browsable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Catalogue/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Comparers/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Daves/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Diag/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Diags/@EntryIndexedValue">True</s:Boolean>
Expand Down
8 changes: 4 additions & 4 deletions src/Vogen/BuildInstanceProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ internal static class BuildInstanceProperties
IEnumerable<AttributeData> allAttributes,
SourceProductionContext context,
INamedTypeSymbol voClass,
INamedTypeSymbol? underlyingType)
INamedTypeSymbol underlyingType)
{
return allAttributes.Select(a => Build(a, context, voClass, underlyingType));
}

private static InstanceProperties? Build(AttributeData matchingAttribute,
SourceProductionContext context,
INamedTypeSymbol voClass,
INamedTypeSymbol? underlyingType)
INamedTypeSymbol underlyingType)
{
// try build it from non-named arguments

Expand Down Expand Up @@ -82,7 +82,7 @@ internal static class BuildInstanceProperties
TypedConstant commentConstant,
INamedTypeSymbol voClass,
SourceProductionContext context,
INamedTypeSymbol? underlyingType)
INamedTypeSymbol underlyingType)
{
bool hasErrors = false;
if (nameConstant.Value is null)
Expand All @@ -104,7 +104,7 @@ internal static class BuildInstanceProperties

var r = InstanceGeneration.TryBuildInstanceValueAsText(
(string)nameConstant.Value!,
valueConstant.Value!, underlyingType?.FullName());
valueConstant.Value!, underlyingType.FullName());

if (!r.Success)
{
Expand Down
Loading

0 comments on commit 24b2f1a

Please sign in to comment.