Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix CS0518: Add IsExternalInit stub for netstandard2.0 in Analyzers#2178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jzabroski merged 4 commits intomainfromcopilot/add-isexternalinit-type-stub
Nov 19, 2025

Conversation

Copy link
Contributor

CopilotAI commentedNov 18, 2025
edited
Loading

Fix CI Build Error: IsExternalInit in FluentMigrator.Analyzers

This PR fixes the CI build failure caused by missingSystem.Runtime.CompilerServices.IsExternalInit type when using init-only properties in a netstandard2.0 project.

Problem

The FluentMigrator.Analyzers project targets netstandard2.0 but uses C# 9 init-only properties inMigrationClassDeclaration.cs. The compiler requires theIsExternalInit type to support these properties, but this type is not available in netstandard2.0, causing the build to fail with error CS0518.

Solution

Added a minimalIsExternalInit.cs stub file to the FluentMigrator.Analyzers project that provides the required type. This is a standard polyfill approach for using init-only properties in older target frameworks.

Changes

  • Reproduced the build error (CS0518)
  • Added IsExternalInit.cs stub file to FluentMigrator.Analyzers
  • Verified the build passes after adding the stub
  • Verified the Analyzers tests build successfully
  • Wrapped in#if NETSTANDARD2_0 conditional compilation directive
  • Using static class per feedback

References

Original prompt

Problem: The CI build for fluentmigrator is failing with errors in FluentMigrator.Analyzers: "Predefined type 'System.Runtime.CompilerServices.IsExternalInit' is not defined or imported". The failure occurs because MigrationClassDeclaration.cs uses init-only properties (C# 9 feature) while the analyzers project targets netstandard2.0, which doesn't provide IsExternalInit.

Goal: Add a minimal IsExternalInit type stub to the FluentMigrator.Analyzers project so the project can compile under netstandard2.0 and CI passes. Create a branch, commit the new file, and open a pull request against the repository's default branch.

Files to add/change:

  • Add src/FluentMigrator.Analyzers/IsExternalInit.cs with the following content:

namespace System.Runtime.CompilerServices
{
// Provides the missing IsExternalInit type required for C# init-only properties when building against older target frameworks.
// This type is intentionally minimal; it only exists to satisfy the compiler.
internal static class IsExternalInit { }
}

Notes:

  • This file should be small and have no dependencies. No changes to the existing csproj are required because the SDK will pick up the new .cs file automatically.
  • The commit message should be: "Add IsExternalInit stub to FluentMigrator.Analyzers to support init-only properties on netstandard2.0"
  • The PR title should match the problem_title above and include a short description referencing the failing job: "Fixes CI build error CS0518 (IsExternalInit) in FluentMigrator.Analyzers" and link to the failing job:https://github.com/fluentmigrator/fluentmigrator/actions/runs/19479023456/job/55746412336?pr=2177

Please create the branch, add the file, commit, and open the PR. Do not assign reviewers or merge the PR.

This pull request was created as a result of the following prompt from Copilot chat.

Problem: The CI build for fluentmigrator is failing with errors in FluentMigrator.Analyzers: "Predefined type 'System.Runtime.CompilerServices.IsExternalInit' is not defined or imported". The failure occurs because MigrationClassDeclaration.cs uses init-only properties (C# 9 feature) while the analyzers project targets netstandard2.0, which doesn't provide IsExternalInit.

Goal: Add a minimal IsExternalInit type stub to the FluentMigrator.Analyzers project so the project can compile under netstandard2.0 and CI passes. Create a branch, commit the new file, and open a pull request against the repository's default branch.

Files to add/change:

  • Add src/FluentMigrator.Analyzers/IsExternalInit.cs with the following content:

namespace System.Runtime.CompilerServices
{
// Provides the missing IsExternalInit type required for C# init-only properties when building against older target frameworks.
// This type is intentionally minimal; it only exists to satisfy the compiler.
internal static class IsExternalInit { }
}

Notes:

  • This file should be small and have no dependencies. No changes to the existing csproj are required because the SDK will pick up the new .cs file automatically.
  • The commit message should be: "Add IsExternalInit stub to FluentMigrator.Analyzers to support init-only properties on netstandard2.0"
  • The PR title should match the problem_title above and include a short description referencing the failing job: "Fixes CI build error CS0518 (IsExternalInit) in FluentMigrator.Analyzers" and link to the failing job:https://github.com/fluentmigrator/fluentmigrator/actions/runs/19479023456/job/55746412336?pr=2177

Please create the branch, add the file, commit, and open the PR. Do not assign reviewers or merge the PR.


✨ Let Copilot coding agentset things up for you — coding agent works faster and does higher quality work when set up for your repo.

…nly properties on netstandard2.0Co-authored-by: jzabroski <447485+jzabroski@users.noreply.github.com>
CopilotAI changed the title[WIP] Add IsExternalInit type stub for analyzers projectFix CS0518: Add IsExternalInit stub for netstandard2.0 in AnalyzersNov 18, 2025
CopilotAI requested a review fromjzabroskiNovember 18, 2025 20:00
@github-actions
Copy link

github-actionsbot commentedNov 18, 2025
edited
Loading

Test Results

    1 files  ±0      1 suites  ±0   33s ⏱️ -1s
5 344 tests ±0  5 012 ✅ ±0  332 💤 ±0  0 ❌ ±0 
5 825 runs  ±0  5 229 ✅ ±0  596 💤 ±0  0 ❌ ±0 

Results for commit44e3543. ± Comparison against base commit9c1772f.

♻️ This comment has been updated with latest results.

@jzabroski
Copy link
Collaborator

@copilot The build is still failing.

I think MigrationClassDeclaration.cs may need something like:

#if NETSTANDARDusing System.Runtime.CompilerServices;#endif

… patternCo-authored-by: jzabroski <447485+jzabroski@users.noreply.github.com>
Copy link
ContributorAuthor

@copilot The build is still failing.

I think MigrationClassDeclaration.cs may need something like:
...

Changed IsExternalInit fromstatic class to regularclass which is the standard pattern for this polyfill. Commitc62307d.

The build succeeds locally - if CI is still failing, please share the specific error message from the CI logs so I can investigate further.

@jzabroski
Copy link
Collaborator

@copilot I really think the code has to be:

#ifNETSTANDARD2_0namespaceSystem.Runtime.CompilerServices{// This internal class is a polyfill to enable the 'init' keyword for older frameworks.internalstaticclassIsExternalInit{}}#endif

Co-authored-by: jzabroski <447485+jzabroski@users.noreply.github.com>
Copy link
ContributorAuthor

@copilot I really think the code has to be:

...

Updated the code to wrap IsExternalInit in#if NETSTANDARD2_0 conditional and changed back tostatic class. Commit44e3543.

@jzabroskijzabroski marked this pull request as ready for reviewNovember 19, 2025 15:14
@jzabroskijzabroski merged commit8d1a6cb intomainNov 19, 2025
2 of 8 checks passed
@jzabroskijzabroski deleted the copilot/add-isexternalinit-type-stub branchNovember 19, 2025 15:51
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@jzabroskijzabroskiAwaiting requested review from jzabroskijzabroski is a code owner

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@jzabroski

[8]ページ先頭

©2009-2025 Movatter.jp