Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ All notable changes to Facet are documented in this file.
- Added `SetAccessor` parameter to `[Facet]` with `PropertySetAccessor` enum (`Preserve` / `Set` / `Init`) to override the set accessor emitted on all generated properties (#381). Supports the immutable builder pattern: one mutable facet for building, one init-only facet as the frozen read model.
- Each facet type now emits two generated files by default: `{Type}.Properties.g.cs` (property declarations) and `{Type}.Mappings.g.cs` (constructors, projections, and conversion methods). Opt out globally by setting `<Facet_SplitGeneratedFiles>false</Facet_SplitGeneratedFiles>` in your `.csproj` or `Directory.Build.props` to restore the previous single-file output.

### Changed

- `Facet.Extensions.EFCore` no longer passes `Microsoft.EntityFrameworkCore.Design` on to your app. It was meant to be design-time only, but every app using the package shipped it, along with Roslyn and MSBuild assemblies (a minimal .NET 8 app goes from 56 files / 29 MB of output to 19 files / 3.4 MB). **Action needed** if you run `dotnet ef` and your startup project does not reference `Microsoft.EntityFrameworkCore.Design` itself: add it, as EF Core migrations require.
- `Facet.Extensions`, `Facet.Extensions.EFCore`, `Facet.Extensions.EFCore.Mapping` and `Facet.Mapping.Expressions` no longer force `System.Collections.Immutable` 10.x onto .NET 8/9 apps or `System.Security.Cryptography.Xml` 10.0.12 onto any app. Both were build-only workarounds, and Cryptography.Xml 10.0.12 (with its Cryptography.Pkcs dependency) now has known high-severity advisories.

### Fixed

- **Security:** `Facet.Dashboard`'s `RequireAuthentication` / `AuthenticationPolicy` now also protect the JSON API endpoint (`{RoutePrefix}/api/facets`). Previously only the HTML page required authorization, so the JSON API, enabled by default, served the full source and facet model to anonymous callers.
Expand Down
11 changes: 2 additions & 9 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,8 @@
<!-- NOTE: Use 'dotnet pack -c Release' instead of GeneratePackageOnBuild to ensure symbols are properly included in .snupkg files -->
<!-- <GeneratePackageOnBuild Condition="'$(IsPackable)' == 'true'">true</GeneratePackageOnBuild> -->

<!--
Suppress MSB3277 System.Collections.Immutable version conflicts.
This is expected: Facet (netstandard2.0 source generator) uses Roslyn which requires v9.0,
while net8.0 framework provides v8.0. The build system correctly resolves to v8.0 for
net8.0 targets. These warnings are informational and don't indicate a problem.

Suppress CS1591: Missing XML comment for publicly visible type or member.
-->
<NoWarn>$(NoWarn);MSB3277;1591</NoWarn>
<!-- Suppress CS1591: Missing XML comment for publicly visible type or member. -->
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>

<!-- SourceLink configuration for debugging support -->
Expand Down
5 changes: 1 addition & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="10.0.0" />
<PackageVersion Include="System.Collections.Immutable" Version="10.0.11" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
</ItemGroup>

Expand All @@ -33,7 +32,6 @@
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageVersion Include="System.Collections.Immutable" Version="10.0.11" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
Expand All @@ -49,7 +47,6 @@
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.11" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="8.0.11" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.11" />
<PackageVersion Include="System.Collections.Immutable" Version="10.0.11" />
</ItemGroup>

<ItemGroup>
Expand All @@ -73,7 +70,7 @@
<PackageVersion Include="System.Text.Json" Version="8.0.5" />

<!-- Security vulnerability fix: override transitive dependency from EF Core Design -->
<PackageVersion Include="System.Security.Cryptography.Xml" Version="10.0.12" />
<PackageVersion Include="System.Security.Cryptography.Xml" Version="10.0.14" />

<!-- SourceLink for debugging support -->
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="10.0.401" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,4 @@
<None Include="README.md" Pack="true" PackagePath="" />
</ItemGroup>

<!-- Resolve System.Collections.Immutable version conflict -->
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net9.0'">
<PackageReference Include="System.Collections.Immutable" />
</ItemGroup>

<!-- Override transitive dependency with vulnerable version from EFCore.Design -->
<ItemGroup>
<PackageReference Include="System.Security.Cryptography.Xml" />
</ItemGroup>

</Project>
31 changes: 20 additions & 11 deletions src/Facet.Extensions.EFCore/Facet.Extensions.EFCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,25 @@
<PackageReference Include="Microsoft.EntityFrameworkCore" />
<!--
Design-time-only surface (IDesignTimeServices, MigrationsScaffolder) used by the
Design/ folder. EFCore.Design marks itself developmentDependency, so it does not
flow to consumers as a package dependency; 'dotnet ef' loads it into the
design-time host itself, which is the only time the Design/ types are touched.
Design/ folder. PrivateAssets="all" keeps it out of the package's dependencies:
developmentDependency only applies when a package is installed directly, so without
it every consuming app shipped EFCore.Design and its Roslyn/MSBuild closure. Apps
that run 'dotnet ef' already reference EFCore.Design themselves (the tool requires
it), and the design-time host is the only place the Design/ types are touched.
-->
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" PrivateAssets="all" />
<ProjectReference Include="..\Facet.Extensions\Facet.Extensions.csproj" />
</ItemGroup>

<!--
MSB3277 on net8.0 only: EFCore.Design 8 brings Roslyn 4.5, while the generator project
(reaching this build as a transitive project reference) is built against Roslyn 4.8.
Neither is part of this package's output or dependencies, so the conflict is build-local.
-->
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
<NoWarn>$(NoWarn);MSB3277</NoWarn>
</PropertyGroup>

<ItemGroup>
<None Include="FacetEfCoreExtensions.cs" />
</ItemGroup>
Expand All @@ -36,14 +47,12 @@
<None Include="buildTransitive\Facet.Extensions.EFCore.targets" Pack="true" PackagePath="buildTransitive\" />
</ItemGroup>

<!-- Resolve System.Collections.Immutable version conflict -->
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net9.0'">
<PackageReference Include="System.Collections.Immutable" />
</ItemGroup>

<!-- Override transitive dependency with vulnerable version from EFCore.Design -->
<!--
Override the vulnerable System.Security.Cryptography.Xml that EFCore.Design brings in.
Private like EFCore.Design itself: it only matters for this build.
-->
<ItemGroup>
<PackageReference Include="System.Security.Cryptography.Xml" />
<PackageReference Include="System.Security.Cryptography.Xml" PrivateAssets="all" />
</ItemGroup>

</Project>
7 changes: 7 additions & 0 deletions src/Facet.Extensions.EFCore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,13 @@ clean branch.
dotnet add MyApp.Persistence package Facet.Extensions.EFCore
```

`dotnet ef` also needs `Microsoft.EntityFrameworkCore.Design` in your startup project, as in any
EF Core migrations setup. Facet does not bring it in, so it never ships with your app:

```bash
dotnet add MyApp.Web package Microsoft.EntityFrameworkCore.Design
```

```xml
<PropertyGroup>
<FacetEfDesignTime>true</FacetEfDesignTime>
Expand Down
16 changes: 10 additions & 6 deletions src/Facet.Extensions/Facet.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Facet\Facet.csproj" />
</ItemGroup>

<!-- Resolve System.Collections.Immutable version conflict -->
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net9.0'">
<PackageReference Include="System.Collections.Immutable" />
<!--
Becomes the Facet package dependency, keeping generator and runtime helpers in step.
The generator assembly is routed into an item type nothing consumes, so it is neither
compiled against (the Facet package ships no lib/ for consumers either) nor run as an
analyzer on this library. As a plain reference it pulled Roslyn's
System.Collections.Immutable into this build, which then had to be pinned and leaked
to every consumer. ReferenceOutputAssembly="false" would avoid that too, but pack then
drops the package dependency.
-->
<ProjectReference Include="..\Facet\Facet.csproj" OutputItemType="FacetGeneratorOutput" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,4 @@
</None>
</ItemGroup>

<!-- Resolve System.Collections.Immutable version conflict -->
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net9.0'">
<PackageReference Include="System.Collections.Immutable" />
</ItemGroup>

</Project>
Loading