mirror of
https://github.com/BepInEx/dotnet-runtime.git
synced 2026-11-23 03:39:35 -10:00
System.ComponentModel.TypeDescriptor expects certain attributes(defined in System.ComponentModel.Primitives) to override IsDesfaultAttribute and TypeId from System.Attribute. This is not available on .NET Core, so an interface had been supplied for it instead. This design required the projects to depend on each other rather than the ref assemblies, so this removes that dependency by creating a lookup table that should cover the majority of the cases. Commit migrated from https://github.com/dotnet/corefx/commit/14c87f0008f3341c68c45bd0dec7ce6aa93b3bdb
49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
// 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 more information.
|
|
|
|
using System.Collections.Generic;
|
|
using Xunit;
|
|
|
|
namespace System.ComponentModel.Primitives.Tests
|
|
{
|
|
public class ImmutableObjectAttributeTests
|
|
{
|
|
[Fact]
|
|
public void Equals_DifferentValues()
|
|
{
|
|
Assert.False(ImmutableObjectAttribute.Yes.Equals(ImmutableObjectAttribute.No));
|
|
}
|
|
|
|
[Fact]
|
|
public void Equals_SameValue()
|
|
{
|
|
Assert.True(ImmutableObjectAttribute.Yes.Equals(ImmutableObjectAttribute.Yes));
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(true)]
|
|
[InlineData(false)]
|
|
public void GetImmutable(bool value)
|
|
{
|
|
var attribute = new ImmutableObjectAttribute(value);
|
|
|
|
Assert.Equal(value, attribute.Immutable);
|
|
}
|
|
|
|
[Theory]
|
|
[MemberData(nameof(ImmutableAttributesData))]
|
|
public void NameTests(ImmutableObjectAttribute attribute, bool isImmutable)
|
|
{
|
|
Assert.Equal(isImmutable, attribute.Immutable);
|
|
}
|
|
|
|
private static IEnumerable<object[]> ImmutableAttributesData()
|
|
{
|
|
yield return new object[] { ImmutableObjectAttribute.Default, false };
|
|
yield return new object[] { new ImmutableObjectAttribute(true), true };
|
|
yield return new object[] { new ImmutableObjectAttribute(false), false };
|
|
}
|
|
}
|
|
}
|