Skip to content

Commit

Permalink
Fixed property tracking generation to work in a couple different edge… (
Browse files Browse the repository at this point in the history
#1787)

* Fixed property tracking generation to work in a couple different edge cases

* fixed schema
  • Loading branch information
david-driscoll authored Feb 2, 2024
1 parent dbcd036 commit 4611f56
Show file tree
Hide file tree
Showing 68 changed files with 1,477 additions and 798 deletions.
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<PackageVersion Include="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="8.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.4.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
<PackageVersion Include="Microsoft.Reactive.Testing" Version="6.0.0" />
<PackageVersion Include="MicroElements.Swashbuckle.FluentValidation" Version="6.0.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
Expand Down
30 changes: 30 additions & 0 deletions LaunchPad.sln
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".vscode", ".vscode", "{2EB0
.vscode/tasks.json = .vscode/tasks.json
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rocket.Surgery.LaunchPad.Analyzers.roslyn4.6", "src\Analyzers.roslyn4.6\Rocket.Surgery.LaunchPad.Analyzers.roslyn4.6.csproj", "{9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Analyzers.Tests.roslyn4.6", "test\Analyzers.Tests.roslyn4.6\Analyzers.Tests.roslyn4.6.csproj", "{84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -872,6 +876,30 @@ Global
{4A176BF2-DC9D-4D6B-8F36-B672273CF09B}.Release|x64.Build.0 = Release|Any CPU
{4A176BF2-DC9D-4D6B-8F36-B672273CF09B}.Release|x86.ActiveCfg = Release|Any CPU
{4A176BF2-DC9D-4D6B-8F36-B672273CF09B}.Release|x86.Build.0 = Release|Any CPU
{9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Debug|x64.ActiveCfg = Debug|Any CPU
{9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Debug|x64.Build.0 = Debug|Any CPU
{9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Debug|x86.ActiveCfg = Debug|Any CPU
{9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Debug|x86.Build.0 = Debug|Any CPU
{9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Release|Any CPU.Build.0 = Release|Any CPU
{9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Release|x64.ActiveCfg = Release|Any CPU
{9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Release|x64.Build.0 = Release|Any CPU
{9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Release|x86.ActiveCfg = Release|Any CPU
{9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Release|x86.Build.0 = Release|Any CPU
{84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Debug|x64.ActiveCfg = Debug|Any CPU
{84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Debug|x64.Build.0 = Debug|Any CPU
{84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Debug|x86.ActiveCfg = Debug|Any CPU
{84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Debug|x86.Build.0 = Debug|Any CPU
{84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Release|Any CPU.Build.0 = Release|Any CPU
{84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Release|x64.ActiveCfg = Release|Any CPU
{84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Release|x64.Build.0 = Release|Any CPU
{84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Release|x86.ActiveCfg = Release|Any CPU
{84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -937,6 +965,8 @@ Global
{3B269B1C-0BE2-485C-AFB7-BB24ACF0B178} = {C3A456FA-D2FE-4109-8DC3-E8191F878C1E}
{3F3EA1F9-1174-40B6-95DB-4C85FA611BBB} = {D65A8130-6A58-4693-A96C-8C1DFA3CA355}
{2EB0A486-E55F-424C-9EA3-0ABBC10D0257} = {D65A8130-6A58-4693-A96C-8C1DFA3CA355}
{9E08CB1A-1352-40FA-8CEB-0EBCA52689A6} = {8FFDF555-DB50-45F9-9A2D-6410F39151C3}
{84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4} = {DF33E0FB-9790-4654-B60F-8AB22E0CC3D1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {439897C2-CCBD-44FE-B2DC-A3E4670ADA59}
Expand Down
35 changes: 17 additions & 18 deletions sample/Sample.Core/Operations/LaunchRecords/EditLaunchRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,39 @@ public partial record Request : IRequest<LaunchRecordModel>
/// <summary>
/// The updated launch partner
/// </summary>
public string Partner { get; set; } = null!; // TODO: Make generator that can be used to create a writable view model
public string Partner { get; init; } = null!; // TODO: Make generator that can be used to create a writable view model

/// <summary>
/// The updated launch payload
/// </summary>
public string Payload { get; set; } = null!; // TODO: Make generator that can be used to create a writable view model
public string Payload { get; init; } = null!; // TODO: Make generator that can be used to create a writable view model

/// <summary>
/// The updated payload weight
/// </summary>
public double PayloadWeightKg { get; set; } // TODO: Make generator that can be used to create a writable view model
public double PayloadWeightKg { get; init; } // TODO: Make generator that can be used to create a writable view model

/// <summary>
/// The updated actual launch date
/// </summary>
public Instant? ActualLaunchDate { get; set; } // TODO: Make generator that can be used to create a writable view model
public Instant? ActualLaunchDate { get; init; } // TODO: Make generator that can be used to create a writable view model

/// <summary>
/// The scheduled launch date
/// </summary>
public Instant ScheduledLaunchDate { get; set; } // TODO: Make generator that can be used to create a writable view model
public Instant ScheduledLaunchDate { get; init; } // TODO: Make generator that can be used to create a writable view model

/// <summary>
/// The update rocket id
/// </summary>
public RocketId RocketId { get; set; } // TODO: Make generator that can be used to create a writable view model
public RocketId RocketId { get; init; } // TODO: Make generator that can be used to create a writable view model
}

public partial record PatchRequest : IRequest<LaunchRecordModel>, IPropertyTracking<Request>
{
/// <summary>
/// The rocket id
/// </summary>
public LaunchRecordId Id { get; init; }
}
/// <summary>
/// The patch request
/// </summary>
/// <param name="Id">The rocket id</param>
public partial record PatchRequest(LaunchRecordId Id) : IRequest<LaunchRecordModel>, IPropertyTracking<Request>;

private class Mapper : Profile
{
Expand Down Expand Up @@ -107,10 +105,11 @@ private class Handler(RocketDbContext dbContext, IMapper mapper, IMediator media
{
private async Task<LaunchRecord> GetLaunchRecord(LaunchRecordId id, CancellationToken cancellationToken)
{
var rocket = await dbContext.LaunchRecords
.Include(z => z.Rocket)
.FirstOrDefaultAsync(z => z.Id == id, cancellationToken)
.ConfigureAwait(false);
var rocket = await dbContext
.LaunchRecords
.Include(z => z.Rocket)
.FirstOrDefaultAsync(z => z.Id == id, cancellationToken)
.ConfigureAwait(false);
if (rocket == null)
{
throw new NotFoundException();
Expand All @@ -136,4 +135,4 @@ public async Task<LaunchRecordModel> Handle(Request request, CancellationToken c
return mapper.Map<LaunchRecordModel>(rocket);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<NoPackageAnalysis>true</NoPackageAnalysis>
<_Analyzer_Roslyn_Version_>$(MSBuildProjectName.Replace("Rocket.Surgery.LaunchPad.Analyzers.", ""))</_Analyzer_Roslyn_Version_>
<DefineConstants>$(DefineConstants);ROSLYN4_4</DefineConstants>
<DefineConstants>$(DefineConstants);ROSLYN4_0;ROSLYN4_4</DefineConstants>
<IsPackable>false</IsPackable>
<AssemblyName>Rocket.Surgery.LaunchPad.Analyzers</AssemblyName>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<NoPackageAnalysis>true</NoPackageAnalysis>
<_Analyzer_Roslyn_Version_>$(MSBuildProjectName.Replace("Rocket.Surgery.LaunchPad.Analyzers.", ""))</_Analyzer_Roslyn_Version_>
<DefineConstants>$(DefineConstants);ROSLYN4_0;ROSLYN4_4;ROSLYN4_6</DefineConstants>
<IsPackable>false</IsPackable>
<AssemblyName>Rocket.Surgery.LaunchPad.Analyzers</AssemblyName>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" VersionOverride="4.6.0" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<Using Remove="System.Diagnostics.CodeAnalysis.NotNullAttribute" />
<Compile Include="..\Analyzers\**\*.cs" Exclude="..\Analyzers\obj\**\*.cs" />
</ItemGroup>
</Project>
Loading

0 comments on commit 4611f56

Please sign in to comment.