Skip to content

Commit f996a73

Browse files
authored
Add IsExternalInit for relevant TFM's (#83)
1 parent 4bc3d6d commit f996a73

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/ReactiveUI.SourceGenerators/Core/Helpers/AttributeDefinitions.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,5 +259,32 @@ namespace ReactiveUI.SourceGenerators.WinForms;
259259
internal sealed class RoutedControlHostAttribute(string? baseType) : Attribute;
260260
#nullable restore
261261
#pragma warning restore
262+
""";
263+
264+
public const string IsExternalInitType = "System.Runtime.CompilerServices.IsExternalInit";
265+
public const string IsExternalInit = """
266+
// Copyright (c) 2024 .NET Foundation and Contributors. All rights reserved.
267+
// Licensed to the .NET Foundation under one or more agreements.
268+
// The .NET Foundation licenses this file to you under the MIT license.
269+
// See the LICENSE file in the project root for full license information.
270+
271+
// <auto-generated />
272+
#pragma warning disable
273+
274+
#if !NET5_0_OR_GREATER
275+
276+
namespace System.Runtime.CompilerServices;
277+
278+
using System.Diagnostics;
279+
using System.Diagnostics.CodeAnalysis;
280+
281+
/// <summary>
282+
/// Reserved to be used by the compiler for tracking metadata. This class should not be used by developers in source code.
283+
/// </summary>
284+
[ExcludeFromCodeCoverage]
285+
[DebuggerNonUserCode]
286+
static class IsExternalInit;
287+
288+
#endif
262289
""";
263290
}

src/ReactiveUI.SourceGenerators/Reactive/ReactiveGenerator.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
3333

3434
// Add the ReactiveAttribute to the compilation
3535
ctx.AddSource($"{AttributeDefinitions.ReactiveAttributeType}.g.cs", SourceText.From(AttributeDefinitions.ReactiveAttribute, Encoding.UTF8));
36+
37+
// Add the IsExternalInit type to the compilation
38+
ctx.AddSource($"{AttributeDefinitions.IsExternalInitType}.g.cs", SourceText.From(AttributeDefinitions.IsExternalInit, Encoding.UTF8));
3639
});
3740

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

0 commit comments

Comments
 (0)