Skip to content
Closed
49 changes: 24 additions & 25 deletions src/Microsoft.ML.Core/BestFriendAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,33 @@

#if CPUMATH_INFRASTRUCTURE
// CpuMath has its own BestFriend and WantsToBeBestFriends attributes for making itself a standalone module
namespace Microsoft.ML.Internal.CpuMath.Core
namespace Microsoft.ML.Internal.CpuMath.Core;
#else
// This namespace contains the BestFriend and WantsToBeBestFriends attributes generally used in ML.NET project settings
namespace Microsoft.ML
namespace Microsoft.ML;
#endif

/// <summary>
/// Intended to be applied to types and members with internal scope to indicate that friend access of this
/// internal item is OK from another assembly. This restriction applies only to assemblies that declare the
/// <see cref="WantsToBeBestFriendsAttribute"/> assembly level attribute. Note that this attribute is not
/// transferable: an internal member with this attribute does not somehow make a containing internal type
/// accessible. Conversely, neither does marking an internal type make any unmarked internal members accessible.
/// </summary>
[BestFriend]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Constructor
| AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class BestFriendAttribute : Attribute
{
/// <summary>
/// Intended to be applied to types and members with internal scope to indicate that friend access of this
/// internal item is OK from another assembly. This restriction applies only to assemblies that declare the
/// <see cref="WantsToBeBestFriendsAttribute"/> assembly level attribute. Note that this attribute is not
/// transferable: an internal member with this attribute does not somehow make a containing internal type
/// accessible. Conversely, neither does marking an internal type make any unmarked internal members accessible.
/// </summary>
[BestFriend]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Constructor
| AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class BestFriendAttribute : Attribute
{
}
}

/// <summary>
/// This is an assembly level attribute to signal that friend accesses on this assembly should be checked
/// for usage of <see cref="BestFriendAttribute"/>. If this attribute is missing, normal access rules for
/// friends should apply.
/// </summary>
[BestFriend]
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)]
internal sealed class WantsToBeBestFriendsAttribute : Attribute
{
}
/// <summary>
/// This is an assembly level attribute to signal that friend accesses on this assembly should be checked
/// for usage of <see cref="BestFriendAttribute"/>. If this attribute is missing, normal access rules for
/// friends should apply.
/// </summary>
[BestFriend]
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)]
internal sealed class WantsToBeBestFriendsAttribute : Attribute
{
}
25 changes: 12 additions & 13 deletions src/Microsoft.ML.Core/PublicKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@

#if !CPUMATH_INFRASTRUCTURE
// This namespace contains the PublicKey generally used in ML.NET project settings
namespace Microsoft.ML
namespace Microsoft.ML;
#else
// CpuMath module has its own PublicKey for isolating itself from Microsoft.ML.Core
// Note that CpuMath uses its own BestFriend defined in Microsoft.ML.Internal.CpuMath.Core.
namespace Microsoft.ML.Internal.CpuMath.Core
namespace Microsoft.ML.Internal.CpuMath.Core;
#endif

[BestFriend]
internal static class PublicKey
{
[BestFriend]
internal static class PublicKey
{
public const string Value = ", PublicKey=00240000048000009400000006020000002400005253413100040000010001004b86c4cb78549b34bab61a3b1800e23bfeb5b3ec390074041536a7e3cbd97f5f04cf0f857155a8928eaa29ebfd11cfbbad3ba70efea7bda3226c6a8d370a4cd303f714486b6ebc225985a638471e6ef571cc92a4613c00b8fa65d61ccee0cbe5f36330c9a01f4183559f1bef24cc2917c6d913e3a541333a1d05d9bed22b38cb";
public const string TestValue = ", PublicKey=002400000480000094000000060200000024000052534131000400000100010015c01ae1f50e8cc09ba9eac9147cf8fd9fce2cfe9f8dce4f7301c4132ca9fb50ce8cbf1df4dc18dd4d210e4345c744ecb3365ed327efdbc52603faa5e21daa11234c8c4a73e51f03bf192544581ebe107adee3a34928e39d04e524a9ce729d5090bfd7dad9d10c722c0def9ccc08ff0a03790e48bcd1f9b6c476063e1966a1c4";
}
public const string Value = ", PublicKey=00240000048000009400000006020000002400005253413100040000010001004b86c4cb78549b34bab61a3b1800e23bfeb5b3ec390074041536a7e3cbd97f5f04cf0f857155a8928eaa29ebfd11cfbbad3ba70efea7bda3226c6a8d370a4cd303f714486b6ebc225985a638471e6ef571cc92a4613c00b8fa65d61ccee0cbe5f36330c9a01f4183559f1bef24cc2917c6d913e3a541333a1d05d9bed22b38cb";
public const string TestValue = ", PublicKey=002400000480000094000000060200000024000052534131000400000100010015c01ae1f50e8cc09ba9eac9147cf8fd9fce2cfe9f8dce4f7301c4132ca9fb50ce8cbf1df4dc18dd4d210e4345c744ecb3365ed327efdbc52603faa5e21daa11234c8c4a73e51f03bf192544581ebe107adee3a34928e39d04e524a9ce729d5090bfd7dad9d10c722c0def9ccc08ff0a03790e48bcd1f9b6c476063e1966a1c4";
}

[BestFriend]
internal static class InternalPublicKey
{
public const string Value = ", PublicKey=0024000004800000940000000602000000240000525341310004000001000100bd8dded65b44bf8183068bd6dae3b68ba499202b2909640604cf63c7c0ea95bec94a400af533d1132e0dba214f310f666486b50ea91f2697a4fe331eb6a8d7306029344e320dabb7c4c3617472e3088c28dbfcf761a3f1b954a2a64cb865aae873b1d3c3cab344661cd7d5929d1043912908b8dd321889ca11f29d6bf9b9b9a9";
}
[BestFriend]
internal static class InternalPublicKey
{
public const string Value = ", PublicKey=0024000004800000940000000602000000240000525341310004000001000100bd8dded65b44bf8183068bd6dae3b68ba499202b2909640604cf63c7c0ea95bec94a400af533d1132e0dba214f310f666486b50ea91f2697a4fe331eb6a8d7306029344e320dabb7c4c3617472e3088c28dbfcf761a3f1b954a2a64cb865aae873b1d3c3cab344661cd7d5929d1043912908b8dd321889ca11f29d6bf9b9b9a9";
}