Skip to content

TodoApp.Uno: CS1574 unresolved XML doc cref to DatabaseFacade.EnsureCreated #539

Description

@adrianhall

Summary

Database/AppDbContext.cs's XML doc comment on DbContextInitializer references <see cref="DatabaseFacade.EnsureCreated"/>, but DatabaseFacade isn't resolvable because the file has no using Microsoft.EntityFrameworkCore.Infrastructure; (where that type lives):

Database/AppDbContext.cs(42,35): warning CS1574: XML comment has cref attribute 'EnsureCreated' that could not be resolved

CI run: https://github.com/CommunityToolkit/Datasync/actions/runs/29093946725 (todoapp-uno / android job)

This only surfaced on the android head in this run (the Microsoft.Android.Sdk appears to enable GenerateDocumentationFile/doc-comment analysis by default, unlike the other TFMs), but the underlying doc-comment bug is present regardless of head.

Root cause

using Microsoft.EntityFrameworkCore;

namespace TodoApp.Uno.Database;
...
/// <summary>
/// Use this class to initialize the database.  In this sample, we just create
/// the database using <see cref="DatabaseFacade.EnsureCreated"/>.  However, you
/// may want to use migrations.
/// </summary>
public class DbContextInitializer(AppDbContext context) : IDbInitializer

DatabaseFacade is defined in Microsoft.EntityFrameworkCore.Infrastructure, not Microsoft.EntityFrameworkCore, and the file only imports the latter. The C# XML doc compiler can't resolve the cref without the type being in scope (or fully qualified), so it emits CS1574 instead of a working doc link.

Suggested fix

Either:

  1. Add using Microsoft.EntityFrameworkCore.Infrastructure; to Database/AppDbContext.cs, or
  2. Fully qualify the cref: <see cref="Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade.EnsureCreated"/>.

Option 1 is simpler and consistent with the rest of the file's style.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions