Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / System.Runtime.DurableInstancing / System / Runtime / AssertHelper.cs / 1305376 / AssertHelper.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- // This class needs to function even if it was built retail. That is, a debug caller calling against a retail // build of this assembly should still have asserts fire. To achieve that, we need to define DEBUG here. // We do not do the registry override in retail because that would require shipping a test hook. We // do not generally ship test hooks today. #if DEBUG #define DEBUG_FOR_REALS #else #define DEBUG #endif namespace System.Runtime { using System; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.Interop; using System.Security; using System.Runtime.Versioning; static class AssertHelper { [SuppressMessage(FxCop.Category.ReliabilityBasic, FxCop.Rule.InvariantAssertRule, Justification = "Assert implementation")] [ResourceConsumption(ResourceScope.Process)] internal static void FireAssert(string message) { try { #if DEBUG_FOR_REALS InternalFireAssert(ref message); #endif } finally { Debug.Assert(false, message); } } #if DEBUG_FOR_REALS [SuppressMessage(FxCop.Category.Globalization, FxCop.Rule.DoNotPassLiteralsAsLocalizedParameters, Justification = "Debug Only")] [Fx.Tag.SecurityNote(Critical = "Calls into various critical methods", Safe = "Exists only on debug versions")] [SecuritySafeCritical] static void InternalFireAssert(ref string message) { try { string debugMessage = "Assert fired! --> " + message + "\r\n"; if (Debugger.IsAttached) { Debugger.Log(0, Debugger.DefaultCategory, debugMessage); Debugger.Break(); } if (UnsafeNativeMethods.IsDebuggerPresent()) { UnsafeNativeMethods.OutputDebugString(debugMessage); UnsafeNativeMethods.DebugBreak(); } if (Fx.AssertsFailFast) { try { Fx.Exception.TraceFailFast(message); } finally { Environment.FailFast(message); } } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } string newMessage = "Exception during FireAssert!"; try { newMessage = string.Concat(newMessage, " [", exception.GetType().Name, ": ", exception.Message, "] --> ", message); } finally { message = newMessage; } throw; } } #endif } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- MonthCalendarDesigner.cs
- unitconverter.cs
- HyperLinkField.cs
- AsymmetricSignatureDeformatter.cs
- Matrix.cs
- ExtendedProperty.cs
- Profiler.cs
- ProjectionQueryOptionExpression.cs
- SchemeSettingElement.cs
- CategoriesDocument.cs
- Label.cs
- TypeHelpers.cs
- XmlNavigatorStack.cs
- RootAction.cs
- CheckableControlBaseAdapter.cs
- ValidationPropertyAttribute.cs
- Util.cs
- BaseResourcesBuildProvider.cs
- TitleStyle.cs
- ToolStripLocationCancelEventArgs.cs
- OleDragDropHandler.cs
- ColumnHeaderConverter.cs
- MemberListBinding.cs
- ValidatorCompatibilityHelper.cs
- PinnedBufferMemoryStream.cs
- DataComponentMethodGenerator.cs
- ClientSideQueueItem.cs
- DiscoveryInnerClientManaged11.cs
- Parsers.cs
- SmtpReplyReaderFactory.cs
- ClientEventManager.cs
- MatrixCamera.cs
- BStrWrapper.cs
- DetailsViewCommandEventArgs.cs
- ValidationErrorEventArgs.cs
- CodeGotoStatement.cs
- IntSecurity.cs
- GeneralTransform3DCollection.cs
- ManagedWndProcTracker.cs
- XmlUnspecifiedAttribute.cs
- Array.cs
- GlyphRunDrawing.cs
- TextElementCollectionHelper.cs
- ReadContentAsBinaryHelper.cs
- SSmlParser.cs
- ConfigurationStrings.cs
- ComponentConverter.cs
- TextElementCollection.cs
- EmbeddedMailObjectsCollection.cs
- GACIdentityPermission.cs
- TableSectionStyle.cs
- PropertyDescriptorComparer.cs
- PeerObject.cs
- HitTestFilterBehavior.cs
- WebServiceMethodData.cs
- SystemIcons.cs
- ProgressBarAutomationPeer.cs
- StrokeNodeData.cs
- RowSpanVector.cs
- ApplicationId.cs
- SQLStringStorage.cs
- QueryPageSettingsEventArgs.cs
- CustomAttributeBuilder.cs
- XmlSignatureManifest.cs
- LinkedList.cs
- NameObjectCollectionBase.cs
- CacheOutputQuery.cs
- DeflateInput.cs
- PreparingEnlistment.cs
- EasingKeyFrames.cs
- MouseGestureConverter.cs
- Imaging.cs
- FolderLevelBuildProviderCollection.cs
- ListViewDeleteEventArgs.cs
- UriSection.cs
- StatusBarPanelClickEvent.cs
- DockProviderWrapper.cs
- Int32EqualityComparer.cs
- NameObjectCollectionBase.cs
- GeometryDrawing.cs
- WebPartConnectionsConnectVerb.cs
- ConstraintCollection.cs
- SerTrace.cs
- CreateParams.cs
- KeyPressEvent.cs
- CodeMemberMethod.cs
- ThaiBuddhistCalendar.cs
- GlobalizationAssembly.cs
- ExpandSegment.cs
- DbgUtil.cs
- RuleProcessor.cs
- BrushValueSerializer.cs
- Point3DCollectionValueSerializer.cs
- SerializationFieldInfo.cs
- CodeDomDecompiler.cs
- WeakEventManager.cs
- ColumnMapVisitor.cs
- XmlEntityReference.cs
- SplineQuaternionKeyFrame.cs
- securitycriticaldataformultiplegetandset.cs