< Summary

Class:Microsoft.Azure.ServiceBus.Primitives.Fx
Assembly:Microsoft.Azure.ServiceBus
File(s):C:\Git\azure-sdk-for-net\sdk\servicebus\Microsoft.Azure.ServiceBus\src\Primitives\Fx.cs
Covered lines:3
Uncovered lines:65
Coverable lines:68
Total lines:306
Line coverage:4.4% (3 of 68)
Covered branches:2
Total branches:10
Branch coverage:20% (2 of 10)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_Exception()-100%100%
.ctor(...)-0%100%
get_Location()-0%100%
get_Description()-0%100%
.ctor(...)-0%0%
get_ElementType()-0%100%
get_CacheAttrition()-0%100%
get_Scope()-0%100%
get_SizeLimit()-0%100%
get_Timeout()-0%100%
.ctor(...)-0%0%
get_ElementType()-0%100%
get_Scope()-0%100%
get_SizeLimit()-0%100%
get_StaleElementsRemovedImmediately()-0%100%
get_EnqueueThrowsIfFull()-0%100%
.ctor()-0%100%
get_Blocking()-0%100%
get_Scope()-0%100%
get_Kind()-0%100%
.ctor(...)-0%100%
get_BlocksUsing()-0%100%
get_SupportsAsync()-0%100%
get_Spins()-0%100%
get_ReleaseMethod()-0%100%
get_CancelMethod()-0%100%
get_CancelDeclaringType()-0%100%
get_Conditional()-0%100%
.ctor(...)-0%0%
get_ExceptionType()-0%100%
get_Diagnosis()-0%100%
get_FromDeclaringType()-0%100%
get_From()-0%100%
get_Critical()-0%100%
get_Safe()-0%100%
get_Miscellaneous()-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\servicebus\Microsoft.Azure.ServiceBus\src\Primitives\Fx.cs

#LineLine coverage
 1// Copyright (c) Microsoft. All rights reserved.
 2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
 3
 4namespace Microsoft.Azure.ServiceBus.Primitives
 5{
 6    using System;
 7    using System.Diagnostics;
 8
 9    static class Fx
 10    {
 11        static ExceptionUtility exceptionUtility;
 12
 13        public static ExceptionUtility Exception
 14        {
 15            get
 16            {
 817                if (exceptionUtility == null)
 18                {
 219                    exceptionUtility = new ExceptionUtility();
 20                }
 21
 822                return exceptionUtility;
 23            }
 24        }
 25
 26        public static class Tag
 27        {
 28            public enum CacheAttrition
 29            {
 30                None,
 31                ElementOnTimer,
 32
 33                // A finalizer/WeakReference based cache, where the elements are held by WeakReferences (or hold an
 34                // inner object by a WeakReference), and the weakly-referenced object has a finalizer which cleans the
 35                // item from the cache.
 36                ElementOnGC,
 37
 38                // A cache that provides a per-element token, delegate, interface, or other piece of context that can
 39                // be used to remove the element (such as IDisposable).
 40                ElementOnCallback,
 41
 42                FullPurgeOnTimer,
 43                FullPurgeOnEachAccess,
 44                PartialPurgeOnTimer,
 45                PartialPurgeOnEachAccess,
 46            }
 47
 48            public enum Location
 49            {
 50                InProcess,
 51                OutOfProcess,
 52                LocalSystem,
 53                LocalOrRemoteSystem, // as in a file that might live on a share
 54                RemoteSystem,
 55            }
 56
 57            public enum SynchronizationKind
 58            {
 59                LockStatement,
 60                MonitorWait,
 61                MonitorExplicit,
 62                InterlockedNoSpin,
 63                InterlockedWithSpin,
 64
 65                // Same as LockStatement if the field type is object.
 66                FromFieldType,
 67            }
 68
 69            [Flags]
 70            public enum BlocksUsing
 71            {
 72                MonitorEnter,
 73                MonitorWait,
 74                ManualResetEvent,
 75                AutoResetEvent,
 76                AsyncResult,
 77                IAsyncResult,
 78                PInvoke,
 79                InputQueue,
 80                ThreadNeutralSemaphore,
 81                PrivatePrimitive,
 82                OtherInternalPrimitive,
 83                OtherFrameworkPrimitive,
 84                OtherInterop,
 85                Other,
 86
 87                NonBlocking, // For use by non-blocking SynchronizationPrimitives such as IOThreadScheduler
 88            }
 89
 90            public static class Strings
 91            {
 92                internal const string ExternallyManaged = "externally managed";
 93                internal const string AppDomain = "AppDomain";
 94                internal const string DeclaringInstance = "instance of declaring class";
 95                internal const string Unbounded = "unbounded";
 96                internal const string Infinite = "infinite";
 97            }
 98
 99            [AttributeUsage(
 100                AttributeTargets.Field | AttributeTargets.Method | AttributeTargets.Constructor,
 101                AllowMultiple = true,
 102                Inherited = false)]
 103            [Conditional("CODE_ANALYSIS")]
 104            public sealed class ExternalResourceAttribute : Attribute
 105            {
 106                readonly Location location;
 107                readonly string description;
 108
 0109                public ExternalResourceAttribute(Location location, string description)
 110                {
 0111                    this.location = location;
 0112                    this.description = description;
 0113                }
 114
 0115                public Location Location => this.location;
 116
 0117                public string Description => this.description;
 118            }
 119
 120            [AttributeUsage(AttributeTargets.Field)]
 121            [Conditional("CODE_ANALYSIS")]
 122            public sealed class CacheAttribute : Attribute
 123            {
 124                readonly Type elementType;
 125                readonly CacheAttrition cacheAttrition;
 126
 0127                public CacheAttribute(Type elementType, CacheAttrition cacheAttrition)
 128                {
 0129                    this.Scope = Strings.DeclaringInstance;
 0130                    this.SizeLimit = Strings.Unbounded;
 0131                    this.Timeout = Strings.Infinite;
 132
 0133                    if (elementType == null)
 134                    {
 0135                        throw Fx.Exception.ArgumentNull(nameof(elementType));
 136                    }
 137
 0138                    this.elementType = elementType;
 0139                    this.cacheAttrition = cacheAttrition;
 0140                }
 141
 0142                public Type ElementType => this.elementType;
 143
 0144                public CacheAttrition CacheAttrition => this.cacheAttrition;
 145
 0146                public string Scope { get; set; }
 147
 0148                public string SizeLimit { get; set; }
 149
 0150                public string Timeout { get; set; }
 151            }
 152
 153            [AttributeUsage(AttributeTargets.Field)]
 154            [Conditional("CODE_ANALYSIS")]
 155            public sealed class QueueAttribute : Attribute
 156            {
 157                readonly Type elementType;
 158
 0159                public QueueAttribute(Type elementType)
 160                {
 0161                    this.Scope = Strings.DeclaringInstance;
 0162                    this.SizeLimit = Strings.Unbounded;
 163
 0164                    if (elementType == null)
 165                    {
 0166                        throw Fx.Exception.ArgumentNull(nameof(elementType));
 167                    }
 168
 0169                    this.elementType = elementType;
 0170                }
 171
 0172                public Type ElementType => this.elementType;
 173
 0174                public string Scope { get; set; }
 175
 0176                public string SizeLimit { get; set; }
 177
 0178                public bool StaleElementsRemovedImmediately { get; set; }
 179
 0180                public bool EnqueueThrowsIfFull { get; set; }
 181            }
 182
 183            // Set on a class when that class uses lock (this) - acts as though it were on a field
 184            //     object this;
 185            [AttributeUsage(AttributeTargets.Field | AttributeTargets.Class, Inherited = false)]
 186            [Conditional("CODE_ANALYSIS")]
 187            public sealed class SynchronizationObjectAttribute : Attribute
 188            {
 0189                public SynchronizationObjectAttribute()
 190                {
 0191                    this.Blocking = true;
 0192                    this.Scope = Strings.DeclaringInstance;
 0193                    this.Kind = SynchronizationKind.FromFieldType;
 0194                }
 195
 0196                public bool Blocking { get; set; }
 197
 0198                public string Scope { get; set; }
 199
 0200                public SynchronizationKind Kind { get; set; }
 201            }
 202
 203            [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = true)]
 204            [Conditional("CODE_ANALYSIS")]
 205            public sealed class SynchronizationPrimitiveAttribute : Attribute
 206            {
 207                readonly BlocksUsing blocksUsing;
 208
 0209                public SynchronizationPrimitiveAttribute(BlocksUsing blocksUsing)
 210                {
 0211                    this.blocksUsing = blocksUsing;
 0212                }
 213
 0214                public BlocksUsing BlocksUsing => this.blocksUsing;
 215
 0216                public bool SupportsAsync { get; set; }
 217
 0218                public bool Spins { get; set; }
 219
 0220                public string ReleaseMethod { get; set; }
 221
 222                [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)]
 223                [Conditional("CODE_ANALYSIS")]
 224                public sealed class BlockingAttribute : Attribute
 225                {
 0226                    public string CancelMethod { get; set; }
 227
 0228                    public Type CancelDeclaringType { get; set; }
 229
 0230                    public string Conditional { get; set; }
 231                }
 232
 233                // Sometime a method will call a conditionally-blocking method in such a way that it is guaranteed
 234                // not to block (i.e. the condition can be Asserted false).  Such a method can be marked as
 235                // GuaranteeNonBlocking as an assertion that the method doesn't block despite calling a blocking method.
 236                //
 237                // Methods that don't call blocking methods and aren't marked as Blocking are assumed not to block, so
 238                // they do not require this attribute.
 239                [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)]
 240                [Conditional("CODE_ANALYSIS")]
 241                public sealed class GuaranteeNonBlockingAttribute : Attribute
 242                {
 243                }
 244
 245                [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)]
 246                [Conditional("CODE_ANALYSIS")]
 247                public sealed class NonThrowingAttribute : Attribute
 248                {
 249                }
 250
 251                [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor, AllowMultiple = true, Inherited 
 252                [Conditional("CODE_ANALYSIS")]
 253                public class ThrowsAttribute : Attribute
 254                {
 255                    readonly Type exceptionType;
 256                    readonly string diagnosis;
 257
 0258                    public ThrowsAttribute(Type exceptionType, string diagnosis)
 259                    {
 0260                        if (exceptionType == null)
 261                        {
 0262                            throw Fx.Exception.ArgumentNull(nameof(exceptionType));
 263                        }
 0264                        if (string.IsNullOrEmpty(diagnosis))
 265                        {
 266                            ////throw Fx.Exception.ArgumentNullOrEmpty("diagnosis");
 0267                            throw new ArgumentNullException(nameof(diagnosis));
 268                        }
 269
 0270                        this.exceptionType = exceptionType;
 0271                        this.diagnosis = diagnosis;
 0272                    }
 273
 0274                    public Type ExceptionType => this.exceptionType;
 275
 0276                    public string Diagnosis => this.diagnosis;
 277                }
 278
 279                [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)]
 280                [Conditional("CODE_ANALYSIS")]
 281                public sealed class InheritThrowsAttribute : Attribute
 282                {
 0283                    public Type FromDeclaringType { get; set; }
 284
 0285                    public string From { get; set; }
 286                }
 287
 288                [AttributeUsage(
 289                    AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class |
 290                    AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Me
 291                    AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Inter
 292                    AttributeTargets.Delegate, AllowMultiple = false,
 293                    Inherited = false)]
 294                [Conditional("CODE_ANALYSIS")]
 295                public sealed class SecurityNoteAttribute : Attribute
 296                {
 0297                    public string Critical { get; set; }
 298
 0299                    public string Safe { get; set; }
 300
 0301                    public string Miscellaneous { get; set; }
 302                }
 303            }
 304        }
 305    }
 306}