diff --git a/src/AI/samples/Essentials.AI.Sample/Essentials.AI.Sample.csproj b/src/AI/samples/Essentials.AI.Sample/Essentials.AI.Sample.csproj index dc415f62f2df..44e76794dac9 100644 --- a/src/AI/samples/Essentials.AI.Sample/Essentials.AI.Sample.csproj +++ b/src/AI/samples/Essentials.AI.Sample/Essentials.AI.Sample.csproj @@ -12,6 +12,7 @@ enable enable preview + $(NoWarn);MAUIAI0001 SourceGen maccatalyst-x64 diff --git a/src/AI/src/Essentials.AI/DiagnosticIds.cs b/src/AI/src/Essentials.AI/DiagnosticIds.cs new file mode 100644 index 000000000000..2573c8138dab --- /dev/null +++ b/src/AI/src/Essentials.AI/DiagnosticIds.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.Maui.Essentials.AI; + +/// +/// Diagnostic IDs for the Microsoft.Maui.Essentials.AI package. +/// +internal static class DiagnosticIds +{ + /// + /// Experimental API diagnostic IDs. + /// + /// + /// All Essentials.AI experiments share a single diagnostic ID so consumers + /// only need one suppression to opt in: <NoWarn>MAUIAI0001</NoWarn>. + /// Individual constants exist per feature area so that APIs can be graduated + /// to stable independently in the future by assigning distinct IDs. + /// + internal static class Experiments + { + internal const string EssentialsAI = "MAUIAI0001"; + } +} diff --git a/src/AI/src/Essentials.AI/Essentials.AI.csproj b/src/AI/src/Essentials.AI/Essentials.AI.csproj index c289a65af323..e510b106f099 100644 --- a/src/AI/src/Essentials.AI/Essentials.AI.csproj +++ b/src/AI/src/Essentials.AI/Essentials.AI.csproj @@ -12,8 +12,15 @@ - false + true Microsoft.Maui.Essentials.AI + + true + preview + 1 $(DefaultPackageTags);essentials;ai .NET Multi-platform App UI (.NET MAUI) is a cross-platform framework for creating native mobile and desktop apps with C# and XAML. This package contains a collection of cross-platform APIs for working with device AI and local models. diff --git a/src/AI/src/Essentials.AI/Polyfills/ExperimentalAttribute.cs b/src/AI/src/Essentials.AI/Polyfills/ExperimentalAttribute.cs new file mode 100644 index 000000000000..038cb7f496bf --- /dev/null +++ b/src/AI/src/Essentials.AI/Polyfills/ExperimentalAttribute.cs @@ -0,0 +1,46 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#if !NET8_0_OR_GREATER + +namespace System.Diagnostics.CodeAnalysis; + +/// +/// Indicates that an API element is experimental and subject to change without notice. +/// +[AttributeUsage( + AttributeTargets.Class | + AttributeTargets.Struct | + AttributeTargets.Enum | + AttributeTargets.Interface | + AttributeTargets.Delegate | + AttributeTargets.Method | + AttributeTargets.Constructor | + AttributeTargets.Property | + AttributeTargets.Field | + AttributeTargets.Event | + AttributeTargets.Assembly)] +internal sealed class ExperimentalAttribute : Attribute +{ + /// + /// Initializes a new instance of the class. + /// + /// The diagnostic ID associated with this experimental API. + public ExperimentalAttribute(string diagnosticId) + { + DiagnosticId = diagnosticId; + } + + /// + /// Gets the ID that the compiler will use when reporting a use of the API the attribute applies to. + /// + public string DiagnosticId { get; } + + /// + /// Gets or sets the URL for corresponding documentation. + /// The API accepts a format string instead of an actual URL, creating a generic URL that includes the diagnostic ID. + /// + public string? UrlFormat { get; set; } +} + +#endif diff --git a/src/AI/src/Essentials.AI/Properties/AssemblyInfo.cs b/src/AI/src/Essentials.AI/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..8935eeda6159 --- /dev/null +++ b/src/AI/src/Essentials.AI/Properties/AssemblyInfo.cs @@ -0,0 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.CodeAnalysis; +using Microsoft.Maui.Essentials.AI; + +[assembly: Experimental(DiagnosticIds.Experiments.EssentialsAI)] diff --git a/src/AI/tests/Essentials.AI.Benchmarks/Essentials.AI.Benchmarks.csproj b/src/AI/tests/Essentials.AI.Benchmarks/Essentials.AI.Benchmarks.csproj index e843e1145cc1..0de9c3e84daa 100644 --- a/src/AI/tests/Essentials.AI.Benchmarks/Essentials.AI.Benchmarks.csproj +++ b/src/AI/tests/Essentials.AI.Benchmarks/Essentials.AI.Benchmarks.csproj @@ -7,6 +7,7 @@ Essentials.AI.Benchmarks Microsoft.Maui.Essentials.AI.Benchmarks false + $(NoWarn);MAUIAI0001 enable enable diff --git a/src/AI/tests/Essentials.AI.DeviceTests/Essentials.AI.DeviceTests.csproj b/src/AI/tests/Essentials.AI.DeviceTests/Essentials.AI.DeviceTests.csproj index 586cb3eeca77..af19dfefdd42 100644 --- a/src/AI/tests/Essentials.AI.DeviceTests/Essentials.AI.DeviceTests.csproj +++ b/src/AI/tests/Essentials.AI.DeviceTests/Essentials.AI.DeviceTests.csproj @@ -13,6 +13,7 @@ true enable enable + $(NoWarn);MAUIAI0001 808cc184-141a-409e-addd-565c973dbce6 diff --git a/src/AI/tests/Essentials.AI.UnitTests/Essentials.AI.UnitTests.csproj b/src/AI/tests/Essentials.AI.UnitTests/Essentials.AI.UnitTests.csproj index 8e2d119a2729..4686f890f132 100644 --- a/src/AI/tests/Essentials.AI.UnitTests/Essentials.AI.UnitTests.csproj +++ b/src/AI/tests/Essentials.AI.UnitTests/Essentials.AI.UnitTests.csproj @@ -6,6 +6,7 @@ Microsoft.Maui.Essentials.AI.UnitTests false true + $(NoWarn);MAUIAI0001 enable enable