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
- ServiceDescriptionReflector.cs
- Rect3DConverter.cs
- Adorner.cs
- FilteredDataSetHelper.cs
- Dictionary.cs
- SystemTcpStatistics.cs
- WebBrowsableAttribute.cs
- TextEffectCollection.cs
- Canvas.cs
- TreeNodeCollection.cs
- IIS7WorkerRequest.cs
- CodeDomConfigurationHandler.cs
- Preprocessor.cs
- ManagementObject.cs
- RequestStatusBarUpdateEventArgs.cs
- QueryOperationResponseOfT.cs
- XamlClipboardData.cs
- Camera.cs
- SizeAnimationClockResource.cs
- SelectionRange.cs
- PermissionToken.cs
- GeometryDrawing.cs
- InstanceDataCollectionCollection.cs
- SqlRowUpdatingEvent.cs
- PerformanceCountersElement.cs
- AxisAngleRotation3D.cs
- ResourcePart.cs
- TraceFilter.cs
- PropertyInfo.cs
- HttpModuleAction.cs
- ActivityScheduledQuery.cs
- DataGridCaption.cs
- TabletDevice.cs
- DataGridParentRows.cs
- RequiredAttributeAttribute.cs
- StreamUpdate.cs
- NominalTypeEliminator.cs
- BooleanConverter.cs
- WsdlInspector.cs
- DataTable.cs
- MetadataLocation.cs
- NumberFormatter.cs
- EntryPointNotFoundException.cs
- AlignmentXValidation.cs
- HyperLink.cs
- storepermission.cs
- ParallelTimeline.cs
- CancelEventArgs.cs
- SqlCommand.cs
- SoapServerMessage.cs
- InputGestureCollection.cs
- EndpointFilterProvider.cs
- storepermission.cs
- ProfileGroupSettingsCollection.cs
- PassportAuthenticationEventArgs.cs
- CreatingCookieEventArgs.cs
- ViewPort3D.cs
- LogFlushAsyncResult.cs
- HttpCacheVaryByContentEncodings.cs
- FieldToken.cs
- SqlConnectionHelper.cs
- ContentElement.cs
- UITypeEditor.cs
- MonthChangedEventArgs.cs
- parserscommon.cs
- KoreanCalendar.cs
- SettingsPropertyCollection.cs
- LogLogRecordEnumerator.cs
- CustomError.cs
- TemplateEditingVerb.cs
- SpecialFolderEnumConverter.cs
- MultilineStringEditor.cs
- MailBnfHelper.cs
- TimeZone.cs
- WmlFormAdapter.cs
- GraphicsContext.cs
- Object.cs
- TextOutput.cs
- DiagnosticTrace.cs
- SrgsElement.cs
- ChangeBlockUndoRecord.cs
- TreePrinter.cs
- XmlILModule.cs
- TextRange.cs
- StringArrayConverter.cs
- DocumentViewerAutomationPeer.cs
- TreeNodeBinding.cs
- TableColumnCollectionInternal.cs
- XmlAttributes.cs
- TreeNodeCollection.cs
- CompilationAssemblyInstallComponent.cs
- DocumentSignatureManager.cs
- VirtualPath.cs
- TraceProvider.cs
- WeakHashtable.cs
- XamlSerializer.cs
- FilterEventArgs.cs
- UniformGrid.cs
- _ShellExpression.cs
- Int64Animation.cs