Skip to content

Commit

Permalink
Simplify and redesign ThisAssembly.Metadata as a special case of Cons…
Browse files Browse the repository at this point in the history
…tants

This allows us to support Comment attribute, but more importantly, support hierarchical metadata ids to generate the nested class structure like we have in Constants.

Fixes #247
  • Loading branch information
kzu committed Jun 9, 2024
1 parent 4cd6a55 commit 2442c61
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 161 deletions.
1 change: 1 addition & 0 deletions src/ThisAssembly.Git/ThisAssembly.Git.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<LangVersion>latest</LangVersion>
<IsRoslynComponent>true</IsRoslynComponent>
<DevelopmentDependency>true</DevelopmentDependency>
<PackBuildOutput>false</PackBuildOutput>
</PropertyGroup>

<PropertyGroup>
Expand Down
40 changes: 0 additions & 40 deletions src/ThisAssembly.Metadata/CSharp.sbntxt

This file was deleted.

76 changes: 0 additions & 76 deletions src/ThisAssembly.Metadata/MetadataGenerator.cs

This file was deleted.

16 changes: 0 additions & 16 deletions src/ThisAssembly.Metadata/Model.cs

This file was deleted.

10 changes: 4 additions & 6 deletions src/ThisAssembly.Metadata/ThisAssembly.Metadata.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<IsRoslynComponent>true</IsRoslynComponent>
<PackBuildOutput>false</PackBuildOutput>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -54,13 +55,10 @@ C#:
<!--<PackageReference Include="Devlooped.SponsorLink" Version="1.0.0" />-->
<PackageReference Include="NuGetizer" Version="1.2.2" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all" />
</ItemGroup>

<PackageReference Include="Scriban" Version="5.10.0" Pack="false" IncludeAssets="build" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />

<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" Pack="false" />
<PackageReference Include="PolySharp" Version="1.14.1" PrivateAssets="All" />
<ItemGroup>
<ProjectReference Include="..\ThisAssembly.Constants\ThisAssembly.Constants.csproj" />
</ItemGroup>

<Import Project="..\Shared\Shared.projitems" Label="Shared" />
Expand Down
8 changes: 8 additions & 0 deletions src/ThisAssembly.Metadata/ThisAssembly.Metadata.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,13 @@
<PackageReference Update="ThisAssembly.Metadata" PrivateAssets="all" PackTransitive="false" />
</ItemGroup>

<Target Name="PrepareMetadataConstants"
BeforeTargets="PrepareConstants"
DependsOnTargets="GetAssemblyAttributes">
<ItemGroup>
<Constant Include="%(AssemblyMetadata.Identity)" Value="%(AssemblyMetadata.Value)" Comment="%(AssemblyMetadata.Comment)" Root="Metadata" />
</ItemGroup>
</Target>

<Import Condition="'$(ThisAssemblyPrerequisitesImported)' != 'true'" Project="ThisAssembly.Prerequisites.targets" />
</Project>
22 changes: 0 additions & 22 deletions src/ThisAssembly.Metadata/Visual Basic.sbntxt

This file was deleted.

4 changes: 4 additions & 0 deletions src/ThisAssembly.Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public void CanUseFileConstantLinkedFile()
public void CanUseMetadata()
=> Assert.Equal("Bar", ThisAssembly.Metadata.Foo);

[Fact]
public void CanUseHierarchicalMetadata()
=> Assert.Equal("Baz", ThisAssembly.Metadata.Root.Foo.Bar);

[Fact]
public void CanUseProjectProperty()
=> Assert.Equal("Bar", ThisAssembly.Project.Foo);
Expand Down
3 changes: 2 additions & 1 deletion src/ThisAssembly.Tests/ThisAssembly.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<ItemGroup>
<ProjectReference Include="..\ThisAssembly.AssemblyInfo\ThisAssembly.AssemblyInfo.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\ThisAssembly.Constants\ThisAssembly.Constants.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\ThisAssembly.Metadata\ThisAssembly.Metadata.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\ThisAssembly.Metadata\ThisAssembly.Metadata.csproj" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\ThisAssembly.Project\ThisAssembly.Project.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\ThisAssembly.Resources\ThisAssembly.Resources.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\ThisAssembly.Strings\ThisAssembly.Strings.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
Expand Down Expand Up @@ -72,6 +72,7 @@
</FileConstant>
<AssemblyMetadata Include="Foo" Value="Bar" />
<AssemblyMetadata Include="Raw" Value="$(Multiline)" />
<AssemblyMetadata Include="Root.Foo.Bar" Value="Baz" Comment="Comment" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 2442c61

Please sign in to comment.