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
- XmlDataSourceView.cs
- SaveFileDialogDesigner.cs
- DispatcherOperation.cs
- BoolExpr.cs
- ProxyWebPartManager.cs
- ActivationServices.cs
- RenderDataDrawingContext.cs
- BoundColumn.cs
- TreeNodeCollectionEditorDialog.cs
- TreeIterator.cs
- UTF7Encoding.cs
- TimeSpanHelper.cs
- XmlSchemaSimpleContent.cs
- TimeZoneNotFoundException.cs
- TemplateKey.cs
- PageWrapper.cs
- TextElementCollection.cs
- NamedPipeHostedTransportConfiguration.cs
- AssemblyResourceLoader.cs
- SpecularMaterial.cs
- BitmapInitialize.cs
- RepeaterItem.cs
- HandleRef.cs
- Span.cs
- StreamSecurityUpgradeInitiatorAsyncResult.cs
- WebBrowserNavigatingEventHandler.cs
- ClientFormsAuthenticationCredentials.cs
- Utils.cs
- FormatConvertedBitmap.cs
- _LocalDataStore.cs
- Transform.cs
- DropSource.cs
- ParameterToken.cs
- BeginStoryboard.cs
- TPLETWProvider.cs
- Line.cs
- Light.cs
- AdRotator.cs
- WindowsUpDown.cs
- WriteTimeStream.cs
- ServiceAuthorizationBehavior.cs
- DiscreteKeyFrames.cs
- SoapInteropTypes.cs
- AspNetRouteServiceHttpHandler.cs
- QilValidationVisitor.cs
- ToolStripPanelRenderEventArgs.cs
- SingleAnimation.cs
- RuleSetDialog.cs
- PagerSettings.cs
- XmlSchemaSimpleContentExtension.cs
- SecurityTokenContainer.cs
- Section.cs
- TemplateApplicationHelper.cs
- FatalException.cs
- SelectedDatesCollection.cs
- NavigatorInput.cs
- XmlSchemaComplexContentExtension.cs
- WebPartEventArgs.cs
- CustomError.cs
- RegistrationServices.cs
- ConfigUtil.cs
- Ipv6Element.cs
- TextRangeEditTables.cs
- StylusPlugInCollection.cs
- ComplusTypeValidator.cs
- FunctionImportMapping.cs
- Renderer.cs
- DeriveBytes.cs
- JsonQNameDataContract.cs
- VersionPair.cs
- TableCellCollection.cs
- DriveInfo.cs
- DbReferenceCollection.cs
- ConfigurationValue.cs
- WebPartExportVerb.cs
- AsyncOperationManager.cs
- MetadataHelper.cs
- IgnoreFlushAndCloseStream.cs
- LocalizableResourceBuilder.cs
- HierarchicalDataSourceConverter.cs
- DesignerActionService.cs
- CellCreator.cs
- InheritanceService.cs
- Cursor.cs
- AttributeConverter.cs
- BinHexDecoder.cs
- SpAudioStreamWrapper.cs
- SortDescription.cs
- BorderGapMaskConverter.cs
- Calendar.cs
- CompiledQueryCacheEntry.cs
- AnnotationObservableCollection.cs
- RpcResponse.cs
- ProcessHostMapPath.cs
- AlternateViewCollection.cs
- Rect3D.cs
- FileClassifier.cs
- ProcessRequestAsyncResult.cs
- IndexedString.cs
- FontStretchConverter.cs