Skip to content

Commit

Permalink
Mark StartTime as experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
egil committed Jun 5, 2023
1 parent 809d67a commit debbca7
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace System.Diagnostics.CodeAnalysis;

/// <summary>
/// Indicates that an API element is experimental and subject to change without notice.
/// </summary>
[ExcludeFromCodeCoverage]
[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
{
/// <summary>
/// Initializes a new instance of the <see cref="ExperimentalAttribute"/> class.
/// </summary>
public ExperimentalAttribute()
{
// Intentionally left empty.
}

/// <summary>
/// Initializes a new instance of the <see cref="ExperimentalAttribute"/> class.
/// </summary>
/// <param name="message">Human readable explanation for marking experimental API.</param>
public ExperimentalAttribute(string message)
{
#pragma warning disable R9A014 // Use the 'Microsoft.Extensions.Diagnostics.Throws' class instead of explicitly throwing exception for improved performance
#pragma warning disable R9A039 // Remove superfluous null check when compiling in a nullable context
#pragma warning disable R9A060 // Consider removing unnecessary null coalescing (??) since the left-hand value is statically known not to be null
#pragma warning disable SA1101 // Prefix local calls with this
Message = message ?? throw new ArgumentNullException(nameof(message));
#pragma warning restore SA1101 // Prefix local calls with this
#pragma warning restore R9A060 // Consider removing unnecessary null coalescing (??) since the left-hand value is statically known not to be null
#pragma warning restore R9A039 // Remove superfluous null check when compiling in a nullable context
#pragma warning restore R9A014 // Use the 'Microsoft.Extensions.Diagnostics.Throws' class instead of explicitly throwing exception for improved performance
}

/// <summary>
/// Gets a human readable explanation for marking API as experimental.
/// </summary>
public string? Message { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Threading;
using Microsoft.Shared.Diagnostics;
Expand All @@ -23,6 +24,7 @@ public class FakeTimeProvider : TimeProvider
/// <summary>
/// Gets the time at which the instance of the <see cref="FakeTimeProvider"/> was initialized.
/// </summary>
[Experimental]
public DateTimeOffset StartTime { get; } = new DateTimeOffset(2000, 1, 1, 0, 0, 0, 0, TimeSpan.Zero);

/// <summary>
Expand Down

0 comments on commit debbca7

Please sign in to comment.