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
Original file line number Diff line number Diff line change
Expand Up @@ -259,5 +259,32 @@ namespace ReactiveUI.SourceGenerators.WinForms;
internal sealed class RoutedControlHostAttribute(string? baseType) : Attribute;
#nullable restore
#pragma warning restore
""";

public const string IsExternalInitType = "System.Runtime.CompilerServices.IsExternalInit";
public const string IsExternalInit = """
// Copyright (c) 2024 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

// <auto-generated />
#pragma warning disable

#if !NET5_0_OR_GREATER

namespace System.Runtime.CompilerServices;

using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;

/// <summary>
/// Reserved to be used by the compiler for tracking metadata. This class should not be used by developers in source code.
/// </summary>
[ExcludeFromCodeCoverage]
[DebuggerNonUserCode]
static class IsExternalInit;

#endif
""";
}
3 changes: 3 additions & 0 deletions src/ReactiveUI.SourceGenerators/Reactive/ReactiveGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public void Initialize(IncrementalGeneratorInitializationContext context)

// Add the ReactiveAttribute to the compilation
ctx.AddSource($"{AttributeDefinitions.ReactiveAttributeType}.g.cs", SourceText.From(AttributeDefinitions.ReactiveAttribute, Encoding.UTF8));

// Add the IsExternalInit type to the compilation
ctx.AddSource($"{AttributeDefinitions.IsExternalInitType}.g.cs", SourceText.From(AttributeDefinitions.IsExternalInit, Encoding.UTF8));
});

// Gather info for all annotated command methods (starting from method declarations with at least one attribute)
Expand Down