Skip to content

Commit 35d7152

Browse files
authored
EF Core updates (#17)
1 parent aa7fa44 commit 35d7152

File tree

28 files changed

+777
-187
lines changed

28 files changed

+777
-187
lines changed

.github/workflows/Tests.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags-ignore:
8+
- '*'
9+
10+
jobs:
11+
tests:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- name: Setup dotnet
19+
uses: actions/setup-dotnet@v4
20+
with:
21+
dotnet-version: '9.x'
22+
23+
- name: Install dependencies
24+
run: dotnet restore
25+
26+
- name: Build
27+
run: dotnet build --configuration Release --no-restore
28+
29+
- name: Test
30+
run: dotnet test --no-restore --verbosity normal

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# XDoc.NET
1+
![Tests](https://github.com/BitzArt/XDoc.NET/actions/workflows/Tests.yml/badge.svg)
2+
3+
[![NuGet version](https://img.shields.io/nuget/v/BitzArt.XDoc.svg)](https://www.nuget.org/packages/BitzArt.XDoc/)
4+
[![NuGet downloads](https://img.shields.io/nuget/dt/BitzArt.XDoc.svg)](https://www.nuget.org/packages/BitzArt.XDoc/)
5+
6+
# Overview
27

38
A lightweight and efficient tool for parsing, and managing C# XML documentation comments.
49

XDoc.Net.sln

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitzArt.XDoc.Tests", "tests
1313
EndProject
1414
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitzArt.XDoc.PlainText", "src\Render\BitzArt.XDoc.PlainText\BitzArt.XDoc.PlainText.csproj", "{95283F56-EFD3-4B32-AE26-4E486D186127}"
1515
EndProject
16-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitzArt.XDoc.PlaintText.Tests", "tests\Render\BitzArt.XDoc.PlaintText.Tests\BitzArt.XDoc.PlaintText.Tests.csproj", "{4F4720A9-8DD2-4DFD-B217-A0FAFC6F60D0}"
16+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitzArt.XDoc.PlainText.Tests", "tests\Render\BitzArt.XDoc.PlainText.Tests\BitzArt.XDoc.PlainText.Tests.csproj", "{4F4720A9-8DD2-4DFD-B217-A0FAFC6F60D0}"
1717
EndProject
1818
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{4DF4BD72-775C-4D08-8192-DAD007669051}"
1919
ProjectSection(SolutionItems) = preProject
@@ -30,7 +30,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestAssembly.A", "tests\Mul
3030
EndProject
3131
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestAssembly.B", "tests\MultiAssemblyTests\TestAssembly.B\TestAssembly.B.csproj", "{152D5D7F-EDF8-489C-B2BE-F22E5F63263F}"
3232
EndProject
33-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitzArt.XDoc.EntityFrameworkCore", "src\BitzArt.XDoc.EntityFrameworkCore\BitzArt.XDoc.EntityFrameworkCore.csproj", "{69E03C89-EA2B-4C47-BF61-70C5F9E56550}"
33+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitzArt.XDoc.EntityFrameworkCore", "src\EntityFrameworkCore\BitzArt.XDoc.EntityFrameworkCore\BitzArt.XDoc.EntityFrameworkCore.csproj", "{69E03C89-EA2B-4C47-BF61-70C5F9E56550}"
34+
EndProject
35+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitzArt.XDoc.EntityFrameworkCore.Tests", "tests\EntityFrameworkCore\BitzArt.XDoc.EntityFrameworkCore.Tests\BitzArt.XDoc.EntityFrameworkCore.Tests.csproj", "{3A197906-2E9F-48AE-BB67-092874629CBA}"
36+
EndProject
37+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EntityFrameworkCore", "EntityFrameworkCore", "{5B807A9A-62ED-44BC-BB5F-86FE8923144B}"
38+
EndProject
39+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EntityFrameworkCore", "EntityFrameworkCore", "{F12832C9-3988-40C4-B768-7028BC8273BE}"
3440
EndProject
3541
Global
3642
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -66,6 +72,10 @@ Global
6672
{69E03C89-EA2B-4C47-BF61-70C5F9E56550}.Debug|Any CPU.Build.0 = Debug|Any CPU
6773
{69E03C89-EA2B-4C47-BF61-70C5F9E56550}.Release|Any CPU.ActiveCfg = Release|Any CPU
6874
{69E03C89-EA2B-4C47-BF61-70C5F9E56550}.Release|Any CPU.Build.0 = Release|Any CPU
75+
{3A197906-2E9F-48AE-BB67-092874629CBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
76+
{3A197906-2E9F-48AE-BB67-092874629CBA}.Debug|Any CPU.Build.0 = Debug|Any CPU
77+
{3A197906-2E9F-48AE-BB67-092874629CBA}.Release|Any CPU.ActiveCfg = Release|Any CPU
78+
{3A197906-2E9F-48AE-BB67-092874629CBA}.Release|Any CPU.Build.0 = Release|Any CPU
6979
EndGlobalSection
7080
GlobalSection(SolutionProperties) = preSolution
7181
HideSolutionNode = FALSE
@@ -80,6 +90,9 @@ Global
8090
{401AF0D6-F0A9-43CE-9CB6-B3BFC69FFE31} = {616D63B3-7EF0-40FB-A404-33A221F65577}
8191
{4398E200-26F9-4184-A943-47738FF5EB4E} = {401AF0D6-F0A9-43CE-9CB6-B3BFC69FFE31}
8292
{152D5D7F-EDF8-489C-B2BE-F22E5F63263F} = {401AF0D6-F0A9-43CE-9CB6-B3BFC69FFE31}
83-
{69E03C89-EA2B-4C47-BF61-70C5F9E56550} = {DE8DA5D7-65DB-4FE8-8CF9-52CEB9CE6648}
93+
{69E03C89-EA2B-4C47-BF61-70C5F9E56550} = {5B807A9A-62ED-44BC-BB5F-86FE8923144B}
94+
{3A197906-2E9F-48AE-BB67-092874629CBA} = {F12832C9-3988-40C4-B768-7028BC8273BE}
95+
{5B807A9A-62ED-44BC-BB5F-86FE8923144B} = {DE8DA5D7-65DB-4FE8-8CF9-52CEB9CE6648}
96+
{F12832C9-3988-40C4-B768-7028BC8273BE} = {616D63B3-7EF0-40FB-A404-33A221F65577}
8497
EndGlobalSection
8598
EndGlobal

src/BitzArt.XDoc.EntityFrameworkCore/BitzArt.XDoc.EntityFrameworkCore.csproj

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/BitzArt.XDoc.EntityFrameworkCore/Extensions/PropertyBuilderExtensions.cs

Lines changed: 0 additions & 59 deletions
This file was deleted.

src/BitzArt.XDoc/BitzArt.XDoc.csproj

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,10 @@
2323
<None Include="..\..\README.md" Pack="True" Visible="false" PackagePath="\"/>
2424
</ItemGroup>
2525

26-
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
27-
<DocumentationFile>bin\Debug\BitzArt.XDoc.xml</DocumentationFile>
28-
</PropertyGroup>
29-
30-
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
31-
<DocumentationFile>bin\Release\BitzArt.XDoc.xml</DocumentationFile>
32-
</PropertyGroup>
33-
3426
<ItemGroup>
3527
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
3628
<_Parameter1>BitzArt.XDoc.Tests</_Parameter1>
3729
</AssemblyAttribute>
38-
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
39-
<_Parameter1>BitzArt.XDoc.PlaintText.Tests</_Parameter1>
40-
</AssemblyAttribute>
4130
</ItemGroup>
4231

4332
<ItemGroup>

src/BitzArt.XDoc/Models/TypeDocumentation.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,16 @@ internal TypeDocumentation(XDoc source, Type type, XmlNode? node)
5555

5656
private TMemberDocumentationResult? GetDocumentation<TMemberDocumentationResult>(MemberInfo member)
5757
where TMemberDocumentationResult : MemberDocumentation
58+
{
59+
return (TMemberDocumentationResult?)GetDocumentation(member);
60+
}
61+
62+
internal MemberDocumentation? GetDocumentation(MemberInfo member)
5863
{
5964
var memberInfo = Validate(member);
6065
var memberDocumentation = _memberData.GetValueOrDefault(memberInfo);
6166

62-
return (TMemberDocumentationResult?)memberDocumentation;
67+
return memberDocumentation;
6368
}
6469

6570
private MemberInfo Validate(MemberInfo member)

src/BitzArt.XDoc/XDoc.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ private AssemblyDocumentation Collect(Assembly assembly)
5353
/// <see cref="TypeDocumentation"/> for the specified <see cref="Type"/> if available;
5454
/// otherwise, <see langword="null"/>.
5555
/// </returns>
56-
public TypeDocumentation? Get(Type? type)
57-
=> type is null ? null : Get(type.Assembly)?.GetDocumentation(type);
56+
public TypeDocumentation? Get(Type type)
57+
=> Get(type.Assembly).GetDocumentation(type);
5858

5959
/// <summary>
6060
/// Fetches documentation for the specified <see cref="PropertyInfo"/>.
@@ -64,8 +64,8 @@ private AssemblyDocumentation Collect(Assembly assembly)
6464
/// <see cref="PropertyDocumentation"/> for the specified <see cref="PropertyInfo"/> if available;
6565
/// otherwise, <see langword="null"/>.
6666
/// </returns>
67-
public PropertyDocumentation? Get(PropertyInfo? property)
68-
=> property is null ? null : Get(property.DeclaringType)?.GetDocumentation(property);
67+
public PropertyDocumentation? Get(PropertyInfo property)
68+
=> Get(property.DeclaringType).GetDocumentation(property);
6969

7070
/// <summary>
7171
/// Fetches documentation for the specified <see cref="MethodInfo"/>.
@@ -78,8 +78,8 @@ private AssemblyDocumentation Collect(Assembly assembly)
7878
/// otherwise, <see langword="null"/>.
7979
/// </returns>
8080
/// <exception cref="NotImplementedException"></exception>
81-
public MethodDocumentation? Get(MethodInfo? methodInfo)
82-
=> methodInfo is null ? null : Get(methodInfo.DeclaringType)?.GetDocumentation(methodInfo);
81+
public MethodDocumentation? Get(MethodInfo methodInfo)
82+
=> Get(methodInfo.DeclaringType).GetDocumentation(methodInfo);
8383

8484
/// <summary>
8585
/// Fetches documentation for the specified <see cref="FieldInfo"/>.
@@ -92,6 +92,14 @@ private AssemblyDocumentation Collect(Assembly assembly)
9292
/// otherwise, <see langword="null"/>.
9393
/// </returns>
9494
/// <exception cref="NotImplementedException"></exception>
95-
public FieldDocumentation? Get(FieldInfo? fieldInfo)
96-
=> fieldInfo is null ? null : Get(fieldInfo.DeclaringType)?.GetDocumentation(fieldInfo);
95+
public FieldDocumentation? Get(FieldInfo fieldInfo)
96+
=> Get(fieldInfo.DeclaringType).GetDocumentation(fieldInfo);
97+
98+
/// <summary>
99+
///
100+
/// </summary>
101+
/// <param name="memberInfo"></param>
102+
/// <returns></returns>
103+
public MemberDocumentation? Get(MemberInfo memberInfo)
104+
=> Get(memberInfo.DeclaringType).GetDocumentation(memberInfo);
97105
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
8+
<RootNamespace>BitzArt.XDoc</RootNamespace>
9+
10+
<PackageId>BitzArt.XDoc.EntityFrameworkCore</PackageId>
11+
<Authors>BitzArt</Authors>
12+
<Description>Extension library that bridges XML documentation comments from C# code to Entity Framework Core database objects.</Description>
13+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
14+
<RepositoryType>git</RepositoryType>
15+
<RepositoryUrl>https://github.com/BitzArt/xdoc</RepositoryUrl>
16+
<PackageProjectUrl>https://github.com/BitzArt/xdoc</PackageProjectUrl>
17+
<PackageReadmeFile>README.md</PackageReadmeFile>
18+
<PackageIcon>xdoc-logo.png</PackageIcon>
19+
</PropertyGroup>
20+
21+
<ItemGroup>
22+
<None Include="..\..\..\assets\xdoc-logo.png" Pack="True" Visible="false" PackagePath="\" />
23+
<None Include="..\..\..\README.md" Pack="True" Visible="false" PackagePath="\" />
24+
</ItemGroup>
25+
26+
<ItemGroup>
27+
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0" PrivateAssets="All"/>
28+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.2"/>
29+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.2"/>
30+
</ItemGroup>
31+
32+
<ItemGroup>
33+
<ProjectReference Include="..\..\BitzArt.XDoc\BitzArt.XDoc.csproj"/>
34+
<ProjectReference Include="..\..\Render\BitzArt.XDoc.PlainText\BitzArt.XDoc.PlainText.csproj"/>
35+
</ItemGroup>
36+
37+
<ItemGroup>
38+
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
39+
<_Parameter1>BitzArt.XDoc.EntityFrameworkCore.Tests</_Parameter1>
40+
</AssemblyAttribute>
41+
</ItemGroup>
42+
43+
</Project>

src/BitzArt.XDoc.EntityFrameworkCore/EntitiesCommentConfigurator.cs renamed to src/EntityFrameworkCore/BitzArt.XDoc.EntityFrameworkCore/EntitiesCommentConfigurator.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
1-
using BitzArt.XDoc.PlainText;
21
using JetBrains.Annotations;
32
using Microsoft.EntityFrameworkCore;
4-
using Microsoft.Extensions.Logging;
53

6-
namespace BitzArt.XDoc.EntityFrameworkCore;
4+
namespace BitzArt.XDoc;
75

86
/// <summary>
97
/// Configures XML documentation comments for Entity Framework Core entities and their properties.
108
/// </summary>
119
[PublicAPI]
1210
public class EntitiesCommentConfigurator
1311
{
14-
private readonly ILogger _logger;
1512
private readonly XDoc _xDoc;
1613

1714
/// <summary>
1815
/// Default constructor.
1916
/// </summary>
20-
public EntitiesCommentConfigurator(XDoc xDoc, ILogger<EntitiesCommentConfigurator> logger)
17+
public EntitiesCommentConfigurator(XDoc xDoc)
2118
{
22-
_logger = logger;
2319
_xDoc = xDoc;
2420
}
2521

@@ -54,8 +50,6 @@ public void ConfigureComments(ModelBuilder modelBuilder)
5450

5551
if (isShadowProperty)
5652
{
57-
_logger.LogInformation($"Skipping shadow property [Name: {property.Name}]");
58-
5953
continue;
6054
}
6155

@@ -65,7 +59,7 @@ public void ConfigureComments(ModelBuilder modelBuilder)
6559
{
6660
return;
6761
}
68-
62+
6963
var propertyComment = _xDoc.Get(propertyInfo).ToPlainText();
7064

7165
property.SetComment(propertyComment);

0 commit comments

Comments
 (0)