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
25 changes: 16 additions & 9 deletions docs/wiki/Packaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,28 @@ analyzer assemblies and their runtime dependencies. The bundled projects are:

- `SourceGeneratorFramework.Generators` — `AttributeDataModelGenerator`, `TypeLibraryGenerator`;
- `SourceGeneratorFramework.Analyzers` — the `PSGFR*` and `TLB*` analyzers;
- `SourceGeneratorFramework.CodeFixers` — the code fix providers;
- `SourceGeneratorShared` — shared models and helpers, packed into the package as
`Purview.SourceGeneratorFramework.Shared.dll`.
- `SourceGeneratorFramework.CodeFixers` — the code fix providers.

The shared models and helpers that used to ship as a separate
`Purview.SourceGeneratorFramework.Shared.dll` are compiled directly into the framework assembly
(`SourceGeneratorFramework` links the `SourceGeneratorShared` sources via
`SourceGeneratorShared.Link.targets`). Consumers therefore receive a single
`Purview.SourceGeneratorFramework.dll`, which removes the version-skew hazard that a separately
bundled Shared assembly caused: generator packages that loaded a different Shared version in-process
failed with binary-incompatibility errors (e.g. removed `PurviewTypeLibrary` fields).

These projects are `IsRoslynComponent = true` and are **not** packable on their own; they are packed
into the main package by the `SourceGeneratorFramework` project via analyzer project references
(`OutputItemType="Analyzer"`).
into the main package by the `SourceGeneratorFramework` project. They were previously consumed as
analyzer project references, but since they now reference the framework assembly for the shared types
(which would form a project-reference cycle), the `SourceGeneratorFramework` project builds them via
`GetSourceGeneratorAnalyzerFiles` and packs them under `analyzers/dotnet/cs/` in
`BuildAndPackBundledAnalyzerAssemblies`.

The repo's pack validation (`purview-build.json`) requires the `purview.sourcegeneratorframework`
package to contain, at minimum:

- `lib/netstandard2.0/Purview.SourceGeneratorFramework.dll` and
`lib/netstandard2.0/Purview.SourceGeneratorFramework.Shared.dll`;
- `analyzers/dotnet/cs/` versions of the framework, generators, analyzers, code fixers, and shared
assemblies;
- `lib/netstandard2.0/Purview.SourceGeneratorFramework.dll`;
- `analyzers/dotnet/cs/` versions of the framework, generators, analyzers, and code fixers;
- `build/Purview.SourceGeneratorFramework.props` and `build/Purview.SourceGeneratorFramework.targets`;
- `README.md`, `LICENSE.md`, and `purview-logo-light.png`.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "purview-sourcegenerator-framework",
"version": "1.0.0-prerelease.46",
"version": "1.0.0-prerelease.47",
"license": "MIT",
"author": {
"name": "Kieron Lanning",
Expand Down
4 changes: 0 additions & 4 deletions purview-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
"RequiredContent": {
"purview.sourcegeneratorframework": [
"lib/netstandard2.0/Purview.SourceGeneratorFramework.dll",
"lib/netstandard2.0/Purview.SourceGeneratorFramework.Shared.dll",
"analyzers/dotnet/cs/Purview.SourceGeneratorFramework.dll",
"analyzers/dotnet/cs/Purview.SourceGeneratorFramework.Generators.dll",
"analyzers/dotnet/cs/Purview.SourceGeneratorFramework.Analyzers.dll",
"analyzers/dotnet/cs/Purview.SourceGeneratorFramework.CodeFixers.dll",
"analyzers/dotnet/cs/Purview.SourceGeneratorFramework.Shared.dll",
"build/Purview.SourceGeneratorFramework.props",
"build/Purview.SourceGeneratorFramework.targets",
"README.md",
Expand All @@ -25,15 +23,13 @@
],
"purview.sourcegeneratorframework.testing": [
"lib/netstandard2.0/Purview.SourceGeneratorFramework.Testing.dll",
"lib/netstandard2.0/Purview.SourceGeneratorFramework.Shared.dll",
"build/Purview.SourceGeneratorFramework.Testing.props",
"README.md",
"LICENSE.md",
"purview-logo-light.png"
],
"purview.sourcegeneratorframework.testing.tunit": [
"lib/netstandard2.0/Purview.SourceGeneratorFramework.Testing.TUnit.dll",
"lib/netstandard2.0/Purview.SourceGeneratorFramework.Shared.dll",
"build/Purview.SourceGeneratorFramework.Testing.TUnit.props",
"README.md",
"LICENSE.md",
Expand Down
1 change: 0 additions & 1 deletion src/SourceGeneratorFramework.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<Project Path="src/SourceGeneratorFramework.Testing.TUnit/SourceGeneratorFramework.Testing.TUnit.csproj" />
<Project Path="src/SourceGeneratorFramework.Testing/SourceGeneratorFramework.Testing.csproj" />
<Project Path="src/SourceGeneratorFramework/SourceGeneratorFramework.csproj" />
<Project Path="src/SourceGeneratorShared/SourceGeneratorShared.csproj" />
</Folder>
<Folder Name="/src/examples/">
<Project Path="src/SourceGeneratorFramework.ExampleGenerator.CodeFixers/SourceGeneratorFramework.ExampleGenerator.CodeFixers.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
<IsRoslynComponent>true</IsRoslynComponent>
<!--
RS2002/RS2003/RS2005 are release-tracking checks that only recognise DiagnosticDescriptors
created within this assembly. The ADM/TLB rules are declared once in SourceGeneratorShared
so the bundled generators can carry them; release tracking cannot verify them here, so these
checks are disabled and the descriptors are tracked as shipped in AnalyzerReleases.Shipped.md.
created within this assembly. The ADM/TLB rules are declared once in the framework
assembly so the bundled generators can carry them; release tracking cannot verify them
here, so these checks are disabled and the descriptors are tracked as shipped in
AnalyzerReleases.Shipped.md.
-->
<NoWarn>$(NoWarn);RS2002;RS2003;RS2005;</NoWarn>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\SourceGeneratorShared\SourceGeneratorShared.csproj" />
<ProjectReference Include="..\SourceGeneratorFramework\SourceGeneratorFramework.csproj" />
</ItemGroup>

<ItemGroup>
Expand All @@ -24,29 +25,16 @@
</ItemGroup>

<Target
Name="DeclareSourceGeneratorSharedRuntimeDependency"
Name="DeclareFrameworkRuntimeDependency"
BeforeTargets="CopySourceGeneratorRuntimeDependencies;GetSourceGeneratorAnalyzerFiles"
>
<ItemGroup>
<SourceGeneratorRuntimeDependency
Include="@(ReferenceCopyLocalPaths)"
Condition="'%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)' == 'Purview.SourceGeneratorFramework.Shared.dll'"
Condition="'%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)' == 'Purview.SourceGeneratorFramework.dll'"
>
<DestinationSubPath>%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)</DestinationSubPath>
</SourceGeneratorRuntimeDependency>
</ItemGroup>
</Target>

<PropertyGroup>
<SourceGeneratorSharedAssembly>$(MSBuildThisFileDirectory)..\SourceGeneratorShared\bin\$(Configuration)\netstandard2.0\Purview.SourceGeneratorFramework.Shared.dll</SourceGeneratorSharedAssembly>
</PropertyGroup>

<Target Name="CopySourceGeneratorSharedToAnalyzerOutput" AfterTargets="CopyFilesToOutputDirectory">
<Copy
SourceFiles="$(SourceGeneratorSharedAssembly)"
DestinationFolder="$(TargetDir)"
SkipUnchangedFiles="true"
Condition="Exists('$(SourceGeneratorSharedAssembly)')"
/>
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

<ItemGroup>
<ProjectReference Include="..\SourceGeneratorFramework.ExampleGenerator.CodeFixers\SourceGeneratorFramework.ExampleGenerator.CodeFixers.csproj" />
<ProjectReference Include="..\SourceGeneratorShared\SourceGeneratorShared.csproj" />
<ProjectReference Include="..\SourceGeneratorFramework\SourceGeneratorFramework.csproj" />
<ProjectReference Include="..\SourceGeneratorFramework.Testing\SourceGeneratorFramework.Testing.csproj" />
<ProjectReference Include="..\SourceGeneratorFramework.Generators\SourceGeneratorFramework.Generators.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\SourceGeneratorShared\SourceGeneratorShared.csproj" />
<ProjectReference Include="..\SourceGeneratorFramework\SourceGeneratorFramework.csproj" />
<ProjectReference Include="..\SourceGeneratorFramework.Analyzers\SourceGeneratorFramework.Analyzers.csproj" />
</ItemGroup>

Expand All @@ -15,29 +15,16 @@
</ItemGroup>

<Target
Name="DeclareSourceGeneratorSharedRuntimeDependency"
Name="DeclareFrameworkRuntimeDependency"
BeforeTargets="CopySourceGeneratorRuntimeDependencies;GetSourceGeneratorAnalyzerFiles"
>
<ItemGroup>
<SourceGeneratorRuntimeDependency
Include="@(ReferenceCopyLocalPaths)"
Condition="'%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)' == 'Purview.SourceGeneratorFramework.Shared.dll'"
Condition="'%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)' == 'Purview.SourceGeneratorFramework.dll'"
>
<DestinationSubPath>%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)</DestinationSubPath>
</SourceGeneratorRuntimeDependency>
</ItemGroup>
</Target>

<PropertyGroup>
<SourceGeneratorSharedAssembly>$(MSBuildThisFileDirectory)..\SourceGeneratorShared\bin\$(Configuration)\netstandard2.0\Purview.SourceGeneratorFramework.Shared.dll</SourceGeneratorSharedAssembly>
</PropertyGroup>

<Target Name="CopySourceGeneratorSharedToAnalyzerOutput" AfterTargets="CopyFilesToOutputDirectory">
<Copy
SourceFiles="$(SourceGeneratorSharedAssembly)"
DestinationFolder="$(TargetDir)"
SkipUnchangedFiles="true"
Condition="Exists('$(SourceGeneratorSharedAssembly)')"
/>
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<PackageReference Include="Purview.SourceGeneratorFramework" PrivateAssets="all" Version="*" />

-->
<ProjectReference Include="..\SourceGeneratorShared\SourceGeneratorShared.csproj" />
<ProjectReference Include="..\SourceGeneratorFramework\SourceGeneratorFramework.csproj" />
<ProjectReference
Include="..\SourceGeneratorFramework.Generators\SourceGeneratorFramework.Generators.csproj"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\SourceGeneratorShared\SourceGeneratorShared.csproj" />
<ProjectReference Include="..\SourceGeneratorFramework\SourceGeneratorFramework.csproj" />
</ItemGroup>

<ItemGroup>
Expand All @@ -13,29 +13,16 @@
</ItemGroup>

<Target
Name="DeclareSourceGeneratorSharedRuntimeDependency"
Name="DeclareFrameworkRuntimeDependency"
BeforeTargets="CopySourceGeneratorRuntimeDependencies;GetSourceGeneratorAnalyzerFiles"
>
<ItemGroup>
<SourceGeneratorRuntimeDependency
Include="@(ReferenceCopyLocalPaths)"
Condition="'%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)' == 'Purview.SourceGeneratorFramework.Shared.dll'"
Condition="'%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)' == 'Purview.SourceGeneratorFramework.dll'"
>
<DestinationSubPath>%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)</DestinationSubPath>
</SourceGeneratorRuntimeDependency>
</ItemGroup>
</Target>

<PropertyGroup>
<SourceGeneratorSharedAssembly>$(MSBuildThisFileDirectory)..\SourceGeneratorShared\bin\$(Configuration)\netstandard2.0\Purview.SourceGeneratorFramework.Shared.dll</SourceGeneratorSharedAssembly>
</PropertyGroup>

<Target Name="CopySourceGeneratorSharedToAnalyzerOutput" AfterTargets="CopyFilesToOutputDirectory">
<Copy
SourceFiles="$(SourceGeneratorSharedAssembly)"
DestinationFolder="$(TargetDir)"
SkipUnchangedFiles="true"
Condition="Exists('$(SourceGeneratorSharedAssembly)')"
/>
</Target>
</Project>
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);IncludeSourceGeneratorShared</TargetsForTfmSpecificContentInPackage>
<TargetsForTfmSpecificDebugSymbolsInPackage>$(TargetsForTfmSpecificDebugSymbolsInPackage);IncludeSourceGeneratorSharedSymbols</TargetsForTfmSpecificDebugSymbolsInPackage>
<TargetFrameworks>netstandard2.0;$(TestingTargetFrameworks)</TargetFrameworks>
<IsPackable>true</IsPackable>
<AssemblyName>$(RootNamespace)</AssemblyName>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\SourceGeneratorFramework.Testing\SourceGeneratorFramework.Testing.csproj" />
<ProjectReference
Include="..\SourceGeneratorShared\SourceGeneratorShared.csproj"
PrivateAssets="all"
Pack="false"
/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="TUnit.Core" />
<PackageReference Include="TUnit.Assertions" />
</ItemGroup>

<Import Project="..\SourceGeneratorShared\SourceGeneratorShared.Pack.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);IncludeSourceGeneratorShared</TargetsForTfmSpecificContentInPackage>
<TargetsForTfmSpecificDebugSymbolsInPackage>$(TargetsForTfmSpecificDebugSymbolsInPackage);IncludeSourceGeneratorSharedSymbols</TargetsForTfmSpecificDebugSymbolsInPackage>
<!-- netstandard2.0 enables net48 consumers (net48 can consume netstandard2.0 but not 2.1). -->
<TargetFrameworks>netstandard2.0;$(TestingTargetFrameworks)</TargetFrameworks>
<IsPackable>true</IsPackable>
Expand All @@ -10,18 +8,11 @@

<ItemGroup>
<ProjectReference Include="..\SourceGeneratorFramework\SourceGeneratorFramework.csproj" />
<ProjectReference
Include="..\SourceGeneratorShared\SourceGeneratorShared.csproj"
PrivateAssets="all"
Pack="false"
/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
<PackageReference Include="System.Reflection.MetadataLoadContext" />
</ItemGroup>

<Import Project="..\SourceGeneratorShared\SourceGeneratorShared.Pack.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,27 @@
<PropertyGroup>
<_PurviewSourceGeneratorFrameworkAssembly Condition="'$(_PurviewSourceGeneratorFrameworkAssembly)' == ''"
>$(MSBuildThisFileDirectory)..\lib\netstandard2.0\Purview.SourceGeneratorFramework.dll</_PurviewSourceGeneratorFrameworkAssembly>
<_PurviewSourceGeneratorFrameworkSharedAssembly
Condition="'$(_PurviewSourceGeneratorFrameworkSharedAssembly)' == ''"
>$(MSBuildThisFileDirectory)..\lib\netstandard2.0\Purview.SourceGeneratorFramework.Shared.dll</_PurviewSourceGeneratorFrameworkSharedAssembly>
<_PurviewSourceGeneratorFrameworkSharedPdb>$([System.IO.Path]::ChangeExtension('$(_PurviewSourceGeneratorFrameworkSharedAssembly)', '.pdb'))</_PurviewSourceGeneratorFrameworkSharedPdb>
<_PurviewSourceGeneratorFrameworkSharedXml>$([System.IO.Path]::ChangeExtension('$(_PurviewSourceGeneratorFrameworkSharedAssembly)', '.xml'))</_PurviewSourceGeneratorFrameworkSharedXml>
</PropertyGroup>

<!--
When a project is a Roslyn component (source generator/analyzer) and references
Purview.SourceGeneratorFramework, ensure the framework runtime DLL is treated as a
runtime dependency of the generator. This lets the dependency be copied next to the
generator and returned as part of the generator's outputs when referenced by other
projects, so the compiler can load it.
projects, so the compiler can load it. The shared types live inside the framework
assembly, so no separate Shared.dll is required.
-->
<ItemGroup Condition="'$(IsRoslynComponent)' == 'true'">
<SourceGeneratorRuntimeDependency Include="$(_PurviewSourceGeneratorFrameworkAssembly)">
<DestinationSubPath>Purview.SourceGeneratorFramework.dll</DestinationSubPath>
</SourceGeneratorRuntimeDependency>
<SourceGeneratorRuntimeDependency Include="$(_PurviewSourceGeneratorFrameworkSharedAssembly)">
<DestinationSubPath>Purview.SourceGeneratorFramework.Shared.dll</DestinationSubPath>
</SourceGeneratorRuntimeDependency>

<_PurviewSourceGeneratorFrameworkRuntimeSidecar
Include="$(_PurviewSourceGeneratorFrameworkSharedPdb)"
Condition="Exists('$(_PurviewSourceGeneratorFrameworkSharedPdb)')"
/>
<_PurviewSourceGeneratorFrameworkRuntimeSidecar
Include="$(_PurviewSourceGeneratorFrameworkSharedXml)"
Condition="Exists('$(_PurviewSourceGeneratorFrameworkSharedXml)')"
/>

<None
Include="$(_PurviewSourceGeneratorFrameworkAssembly)"
Pack="true"
PackagePath="analyzers/dotnet/cs/"
Visible="false"
/>
<None
Include="$(_PurviewSourceGeneratorFrameworkSharedAssembly)"
Pack="true"
PackagePath="analyzers/dotnet/cs/"
Visible="false"
/>
<None
Include="@(_PurviewSourceGeneratorFrameworkRuntimeSidecar)"
Pack="true"
PackagePath="analyzers/dotnet/cs/"
Visible="false"
/>
</ItemGroup>

<Target
Expand All @@ -64,11 +36,5 @@
DestinationFolder="$(TargetDir)"
SkipUnchangedFiles="true"
/>
<Copy
SourceFiles="@(_PurviewSourceGeneratorFrameworkRuntimeSidecar)"
DestinationFolder="$(TargetDir)"
SkipUnchangedFiles="true"
Condition="'@(_PurviewSourceGeneratorFrameworkRuntimeSidecar)' != ''"
/>
</Target>
</Project>
Loading
Loading