Skip to content

Commit

Permalink
Add IsExternalInit for relevant TFM's (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPulman authored Oct 18, 2024
1 parent 4bc3d6d commit f996a73
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
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

0 comments on commit f996a73

Please sign in to comment.