diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlReader.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlReader.cs index 59094d4a14bb..14079fe3ef00 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlReader.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlReader.cs @@ -13,7 +13,6 @@ using System.Collections; using System.Globalization; using System.Xml.Schema; -using System.Runtime.Versioning; #if SILVERLIGHT using BufferBuilder=System.Xml.BufferBuilder; @@ -1531,28 +1530,16 @@ private static XmlTextReaderImpl GetXmlTextReaderImpl(XmlReader reader) { // // Creates an XmlReader for parsing XML from the given Uri. -#if !SILVERLIGHT - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] -#endif public static XmlReader Create(string inputUri) { return XmlReader.Create(inputUri, (XmlReaderSettings)null, (XmlParserContext)null); } // Creates an XmlReader according to the settings for parsing XML from the given Uri. -#if !SILVERLIGHT - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] -#endif public static XmlReader Create(string inputUri, XmlReaderSettings settings) { return XmlReader.Create(inputUri, settings, (XmlParserContext)null); } // Creates an XmlReader according to the settings and parser context for parsing XML from the given Uri. -#if !SILVERLIGHT - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] -#endif public static XmlReader Create(String inputUri, XmlReaderSettings settings, XmlParserContext inputContext) { if (settings == null) { settings = new XmlReaderSettings(); diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlReaderAsync.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlReaderAsync.cs index 61b45155ba8f..62c76a5258c4 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlReaderAsync.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlReaderAsync.cs @@ -6,7 +6,6 @@ using System.Collections; using System.Globalization; using System.Xml.Schema; -using System.Runtime.Versioning; using System.Threading.Tasks; diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlReaderSettings.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlReaderSettings.cs index 925d375fb307..b867b002418f 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlReaderSettings.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlReaderSettings.cs @@ -14,7 +14,6 @@ using System.Xml.Schema; using System.Xml.XmlConfiguration; #endif -using System.Runtime.Versioning; namespace System.Xml { @@ -366,10 +365,6 @@ internal ValidationEventHandler GetEventHandler() { #endif -#if !SILVERLIGHT - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] -#endif internal XmlReader CreateReader(String inputUri, XmlParserContext inputContext) { if (inputUri == null) { throw new ArgumentNullException("inputUri"); diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextReader.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextReader.cs index 3bf6ef13b099..f6ed08c53136 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextReader.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextReader.cs @@ -11,9 +11,7 @@ using System.Text; using System.Xml.Schema; using System.Collections; -using System.Security.Policy; using System.Collections.Generic; -using System.Runtime.Versioning; namespace System.Xml { @@ -86,16 +84,12 @@ public XmlTextReader( string xmlFragment, XmlNodeType fragType, XmlParserContext impl = new XmlTextReaderImpl( xmlFragment, fragType, context ); impl.OuterReader = this; } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + public XmlTextReader( string url ) { impl = new XmlTextReaderImpl( url, new NameTable() ); impl.OuterReader = this; } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + public XmlTextReader( String url, XmlNameTable nt ) { impl = new XmlTextReaderImpl( url, nt ); impl.OuterReader = this; diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextReaderImpl.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextReaderImpl.cs index a37c4992ac23..375b33900680 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextReaderImpl.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextReaderImpl.cs @@ -17,7 +17,6 @@ using System.Globalization; using System.Collections.Generic; using System.Runtime.CompilerServices; -using System.Runtime.Versioning; #if SILVERLIGHT using System.Reflection; @@ -526,10 +525,6 @@ internal XmlTextReaderImpl( string url, TextReader input, XmlNameTable nt ) : th // Initializes a new instance of XmlTextReaderImpl class for parsing fragments with the specified stream, fragment type and parser context // This constructor is used when creating XmlTextReaderImpl for V1 XmlTextReader // SxS: The method resolves URI but does not expose the resolved value up the stack hence Resource Exposure scope is None. -#if !SILVERLIGHT - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] -#endif internal XmlTextReaderImpl( Stream xmlFragment, XmlNodeType fragType, XmlParserContext context ) : this( ( context != null && context.NameTable != null ) ? context.NameTable : new NameTable() ) { @@ -582,17 +577,9 @@ internal XmlTextReaderImpl( string xmlFragment, XmlParserContext context ) // Initializes a new instance of the XmlTextReaderImpl class with the specified url and XmlNameTable. // This constructor is used when creating XmlTextReaderImpl for V1 XmlTextReader -#if !SILVERLIGHT - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] -#endif public XmlTextReaderImpl( string url ) : this( url, new NameTable() ) { } -#if !SILVERLIGHT - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] -#endif public XmlTextReaderImpl( string url, XmlNameTable nt ): this( nt ) { if ( url == null ) { throw new ArgumentNullException( "url" ); @@ -2197,10 +2184,6 @@ internal bool DtdParserProxy_V1CompatibilityMode { internal Uri DtdParserProxy_BaseUri { // SxS: ps.baseUri may be initialized in the constructor (public XmlTextReaderImpl( string url, XmlNameTable nt )) based on // url provided by the user. Here the property returns ps.BaseUri - so it may expose a path. -#if !SILVERLIGHT - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] -#endif get { if ( ps.baseUriStr.Length > 0 && ps.baseUri == null && xmlResolver != null ) { ps.baseUri = xmlResolver.ResolveUri( null, ps.baseUriStr ); @@ -2383,10 +2366,6 @@ internal bool DtdParserProxy_PopEntity( out IDtdEntityInfo oldEntity, out int ne // SxS: The caller did not provide any SxS sensitive name or resource. No resource is being exposed either. // It is OK to suppress SxS warning. -#if !SILVERLIGHT - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] -#endif internal bool DtdParserProxy_PushExternalSubset( string systemId, string publicId ) { Debug.Assert( parsingStatesStackTop == -1 ); Debug.Assert( ( systemId != null && systemId.Length > 0 ) || ( publicId != null && publicId.Length > 0 ) ); @@ -2809,9 +2788,7 @@ private void ProcessDtdFromParserContext(XmlParserContext context) { } #if !SILVERLIGHT // Needed only for XmlTextReader - // SxS: This method resolve Uri but does not expose it to the caller. It's OK to suppress the warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] + // SxS: This method resolve Uri but does not expose it to the caller. It's OK to suppress the warning. private void OpenUrl() { Debug.Assert( url != null && url.Length > 0 ); Debug.Assert( compressedStack != null ); @@ -7096,10 +7073,6 @@ private XmlNodeType GetTextNodeType( int orChars ) { // This method resolves and opens an external DTD subset or an external entity based on its SYSTEM or PUBLIC ID. // SxS: This method may expose a name if a resource in baseUri (ref) parameter. -#if !SILVERLIGHT - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] -#endif private void PushExternalEntityOrSubset( string publicId, string systemId, Uri baseUri, string entityName ) { Uri uri; @@ -7181,10 +7154,6 @@ private bool OpenAndPush( Uri uri ) { // returns true if real entity has been pushed, false if fake entity (=empty content entity) // SxS: The method neither takes any name of resource directly nor it exposes any resource to the caller. // Entity info was created based on source document. It's OK to suppress the SxS warning -#if !SILVERLIGHT - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] -#endif private bool PushExternalEntity( IDtdEntityInfo entity ) { Debug.Assert( entity.IsExternal ); @@ -8463,10 +8432,6 @@ void InitBinHexDecoder() { } // SxS: URIs are resolved only to be compared. No resource exposure. It's OK to suppress the SxS warning. -#if !SILVERLIGHT - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] -#endif bool UriEqual( Uri uri1, string uri1Str, string uri2Str, XmlResolver resolver ) { if (resolver == null) { return uri1Str == uri2Str; diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextReaderImplAsync.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextReaderImplAsync.cs index e22ee8b7ef52..0b79ed003f34 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextReaderImplAsync.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextReaderImplAsync.cs @@ -10,7 +10,6 @@ using System.Globalization; using System.Collections.Generic; using System.Runtime.CompilerServices; -using System.Runtime.Versioning; using System.Threading.Tasks; @@ -779,10 +778,6 @@ internal async Task< Tuple > DtdParserProxy_PushEntityAsync(IDtdEntit // SxS: The caller did not provide any SxS sensitive name or resource. No resource is being exposed either. // It is OK to suppress SxS warning. -#if !SILVERLIGHT - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] -#endif internal async Task< bool > DtdParserProxy_PushExternalSubsetAsync( string systemId, string publicId ) { CheckAsyncCall(); Debug.Assert( parsingStatesStackTop == -1 ); @@ -4731,10 +4726,6 @@ private async Task< string > ParseEntityNameAsync() { // This method resolves and opens an external DTD subset or an external entity based on its SYSTEM or PUBLIC ID. // SxS: This method may expose a name if a resource in baseUri (ref) parameter. -#if !SILVERLIGHT - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] -#endif private async Task PushExternalEntityOrSubsetAsync(string publicId, string systemId, Uri baseUri, string entityName) { @@ -4825,10 +4816,6 @@ private async Task< bool > OpenAndPushAsync( Uri uri ) { // returns true if real entity has been pushed, false if fake entity (=empty content entity) // SxS: The method neither takes any name of resource directly nor it exposes any resource to the caller. // Entity info was created based on source document. It's OK to suppress the SxS warning -#if !SILVERLIGHT - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] -#endif private async Task< bool > PushExternalEntityAsync( IDtdEntityInfo entity ) { Debug.Assert( entity.IsExternal ); diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextReaderImplHelpers.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextReaderImplHelpers.cs index 67c1e760d8ed..ac190c7ec06b 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextReaderImplHelpers.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextReaderImplHelpers.cs @@ -17,7 +17,6 @@ using System.Diagnostics; using System.Globalization; using System.Collections.Generic; -using System.Runtime.Versioning; #if SILVERLIGHT using BufferBuilder=System.Xml.BufferBuilder; @@ -194,10 +193,6 @@ IXmlNamespaceResolver IDtdParserAdapter.NamespaceResolver { Uri IDtdParserAdapter.BaseUri { // SxS: DtdParserProxy_BaseUri property on the reader may expose machine scope resources. This property // is just returning the value of the other property, so it may expose machine scope resource as well. -#if !SILVERLIGHT - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] -#endif get { return reader.DtdParserProxy_BaseUri; } } diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextReaderImplHelpersAsync.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextReaderImplHelpersAsync.cs index 892b3a307919..02a8d3ade1ae 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextReaderImplHelpersAsync.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextReaderImplHelpersAsync.cs @@ -10,7 +10,6 @@ using System.Diagnostics; using System.Globalization; using System.Collections.Generic; -using System.Runtime.Versioning; #if SILVERLIGHT using BufferBuilder=System.Xml.BufferBuilder; diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextWriter.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextWriter.cs index 0f6e6c25e850..d44df2960814 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextWriter.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlTextWriter.cs @@ -12,7 +12,6 @@ using System.Text; using System.Diagnostics; using System.Globalization; -using System.Runtime.Versioning; namespace System.Xml { @@ -272,8 +271,6 @@ public XmlTextWriter(Stream w, Encoding encoding) : this() { } // Creates an instance of the XmlTextWriter class using the specified file. - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] public XmlTextWriter(String filename, Encoding encoding) : this(new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.Read), encoding) { diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlValidatingReaderImpl.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlValidatingReaderImpl.cs index 57f5c5cea649..316e2f6b650f 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlValidatingReaderImpl.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlValidatingReaderImpl.cs @@ -13,9 +13,7 @@ using System.Collections; using System.Diagnostics; using System.Globalization; -using System.Security.Policy; using System.Collections.Generic; -using System.Runtime.Versioning; namespace System.Xml { @@ -150,8 +148,6 @@ internal XmlValidatingReaderImpl( XmlReader reader ) { // Initializes a new instance of XmlValidatingReaderImpl class for parsing fragments with the specified string, fragment type and parser context // This constructor is used when creating XmlValidatingReaderImpl for V1 XmlValidatingReader // SxS: This method resolves an Uri but does not expose it to the caller. It's OK to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] internal XmlValidatingReaderImpl( string xmlFragment, XmlNodeType fragType, XmlParserContext context ) : this( new XmlTextReader( xmlFragment, fragType, context ) ) { @@ -168,8 +164,6 @@ internal XmlValidatingReaderImpl( string xmlFragment, XmlNodeType fragType, XmlP // Initializes a new instance of XmlValidatingReaderImpl class for parsing fragments with the specified stream, fragment type and parser context // This constructor is used when creating XmlValidatingReaderImpl for V1 XmlValidatingReader // SxS: This method resolves an Uri but does not expose it to the caller. It's OK to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] internal XmlValidatingReaderImpl( Stream xmlFragment, XmlNodeType fragType, XmlParserContext context ) : this( new XmlTextReader( xmlFragment, fragType, context ) ) { @@ -882,8 +876,6 @@ private void ResolveEntityInternally() { } // SxS: This method resolves an Uri but does not expose it to caller. It's OK to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] private void SetupValidation( ValidationType valType ) { validator = BaseValidator.CreateInstance( valType, this, schemaCollection, eventHandling , processIdentityConstraints); diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlValidatingReaderImplAsync.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlValidatingReaderImplAsync.cs index efb01fd4c8e4..22383c02971d 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlValidatingReaderImplAsync.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlValidatingReaderImplAsync.cs @@ -6,9 +6,7 @@ using System.Collections; using System.Diagnostics; using System.Globalization; -using System.Security.Policy; using System.Collections.Generic; -using System.Runtime.Versioning; using System.Threading.Tasks; diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlWriter.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlWriter.cs index 0faeb6d76712..44166e27ba5d 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlWriter.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlWriter.cs @@ -16,7 +16,6 @@ using System.Diagnostics; using System.Collections.Generic; using System.Globalization; -using System.Runtime.Versioning; namespace System.Xml { @@ -594,15 +593,11 @@ private void WriteLocalNamespaces(XPathNavigator nsNav) { // #if !SILVERLIGHT // Creates an XmlWriter for writing into the provided file. - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] public static XmlWriter Create(string outputFileName) { return Create(outputFileName, null); } // Creates an XmlWriter for writing into the provided file with the specified settings. - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] public static XmlWriter Create(string outputFileName, XmlWriterSettings settings) { if (settings == null) { settings = new XmlWriterSettings(); diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlWriterAsync.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlWriterAsync.cs index 03cb531f0a9f..b5b6df297318 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlWriterAsync.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlWriterAsync.cs @@ -11,7 +11,6 @@ using System.Diagnostics; using System.Collections.Generic; using System.Globalization; -using System.Runtime.Versioning; namespace System.Xml { diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlWriterSettings.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlWriterSettings.cs index d4bac274f9d2..1f71e418843a 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlWriterSettings.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XmlWriterSettings.cs @@ -9,7 +9,6 @@ using System.Diagnostics; using System.IO; using System.Text; -using System.Runtime.Versioning; #if !SILVERLIGHT #if !HIDE_XSL @@ -427,8 +426,6 @@ internal bool IsQuerySpecific { #endif #if !SILVERLIGHT - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] internal XmlWriter CreateWriter(string outputFileName) { if (outputFileName == null) { throw new ArgumentNullException("outputFileName"); @@ -455,7 +452,7 @@ internal XmlWriter CreateWriter(string outputFileName) { } catch { if (fs != null) { - fs.Close(); + fs.Dispose(); } throw; } diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XsdCachingReader.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XsdCachingReader.cs index 3621274cb73d..f0a8ca92039d 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XsdCachingReader.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XsdCachingReader.cs @@ -13,7 +13,6 @@ using System.Diagnostics; using System.Globalization; using System.Collections; -using System.Security.Policy; namespace System.Xml { diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XsdCachingReaderAsync.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XsdCachingReaderAsync.cs index c632fd8c0ced..8db9a81c8591 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XsdCachingReaderAsync.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XsdCachingReaderAsync.cs @@ -6,7 +6,6 @@ using System.Diagnostics; using System.Globalization; using System.Collections; -using System.Security.Policy; using System.Threading.Tasks; diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XsdValidatingReader.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XsdValidatingReader.cs index e12ff23c7e37..4f591cf9336e 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XsdValidatingReader.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XsdValidatingReader.cs @@ -13,9 +13,7 @@ using System.Diagnostics; using System.Globalization; using System.Collections; -using System.Security.Policy; using System.Collections.Generic; -using System.Runtime.Versioning; namespace System.Xml { @@ -1594,9 +1592,7 @@ private void ProcessReaderEvent() { // SxS: This function calls ValidateElement on XmlSchemaValidator which is annotated with ResourceExposure attribute. // Since the resource names (namespace location) are not provided directly by the user (they are read from the source - // document) and the function does not expose any resources it is fine to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] + // document) and the function does not expose any resources it is fine to suppress the SxS warning. private void ProcessElementEvent() { if (this.processInlineSchema && IsXSDRoot(coreReader.LocalName, coreReader.NamespaceURI) && coreReader.Depth > 0) { xmlSchemaInfo.Clear(); diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XsdValidatingReaderAsync.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XsdValidatingReaderAsync.cs index b30ec8e0ee21..b342e60ec40d 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Core/XsdValidatingReaderAsync.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Core/XsdValidatingReaderAsync.cs @@ -6,9 +6,7 @@ using System.Diagnostics; using System.Globalization; using System.Collections; -using System.Security.Policy; using System.Collections.Generic; -using System.Runtime.Versioning; using System.Threading.Tasks; @@ -441,9 +439,7 @@ private Task ProcessReaderEventAsync() { // SxS: This function calls ValidateElement on XmlSchemaValidator which is annotated with ResourceExposure attribute. // Since the resource names (namespace location) are not provided directly by the user (they are read from the source - // document) and the function does not expose any resources it is fine to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] + // document) and the function does not expose any resources it is fine to suppress the SxS warning. private async Task ProcessElementEventAsync() { if (this.processInlineSchema && IsXSDRoot(coreReader.LocalName, coreReader.NamespaceURI) && coreReader.Depth > 0) { xmlSchemaInfo.Clear(); diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Core/util/TernaryTreeGenerator.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Core/util/TernaryTreeGenerator.cs index 4a2ce77cf191..81a8e2e2b0a9 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Core/util/TernaryTreeGenerator.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Core/util/TernaryTreeGenerator.cs @@ -468,7 +468,7 @@ public static void Main() { ternaryTreeRW.dumpTree(streamWriter, "htmlAttributes"); ternaryTreeRW.OutputFileFooter(streamWriter); fs.Flush(); - fs.Close(); + fs.Dispose(); } catch (Exception ex) { Console.WriteLine(ex.Message); } diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Dom/DocumentSchemaValidator.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Dom/DocumentSchemaValidator.cs index 38dd487682bd..f71c581e6313 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Dom/DocumentSchemaValidator.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Dom/DocumentSchemaValidator.cs @@ -15,9 +15,7 @@ using System.Xml.XPath; using System.Globalization; using System.Security; -using System.Security.Policy; using System.Reflection; -using System.Runtime.Versioning; namespace System.Xml { @@ -292,9 +290,7 @@ private void ValidateNode(XmlNode node) { // SxS: This function calls ValidateElement on XmlSchemaValidator which is annotated with ResourceExposure attribute. // Since the resource names passed to ValidateElement method are null and the function does not expose any resources - // it is fine to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] + // it is fine to suppress the SxS warning. private void ValidateElement() { nsManager.PushScope(); XmlElement elementNode = currentNode as XmlElement; @@ -595,9 +591,7 @@ private XmlSchemaComplexType GetComplexType(XmlSchemaObject schemaObject) { // SxS: This function calls ValidateElement on XmlSchemaValidator which is annotated with ResourceExposure attribute. // Since the resource names passed to ValidateElement method are null and the function does not expose any resources - // it is fine to supress the warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] + // it is fine to supress the warning. private void ValidateSingleElement(XmlElement elementNode, bool skipToEnd, XmlSchemaInfo newSchemaInfo) { nsManager.PushScope(); Debug.Assert(elementNode != null); diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Dom/XmlDocument.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Dom/XmlDocument.cs index 5945f4f5810a..dcbdb1ad1e92 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Dom/XmlDocument.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Dom/XmlDocument.cs @@ -16,7 +16,6 @@ namespace System.Xml using System.Xml.XPath; using System.Security; using System.Globalization; - using System.Runtime.Versioning; // Represents an entire document. An XmlDocument contains XML data. public class XmlDocument: XmlNode { @@ -1058,8 +1057,6 @@ private XmlTextReader SetupReader( XmlTextReader tr ) { } // Loads the XML document from the specified URL. - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] public virtual void Load( string filename ) { XmlTextReader reader = SetupReader( new XmlTextReader( filename, NameTable ) ); try { @@ -1155,8 +1152,6 @@ public override string InnerXml { // Saves the XML document to the specified file. //Saves out the to the file with exact content in the XmlDocument. - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] public virtual void Save( string filename ) { if ( DocumentElement == null ) throw new XmlException( Res.Xml_InvalidXmlDocument, string.Format( Res.Xdom_NoRootEle ) ); diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Dom/XmlDomTextWriter.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Dom/XmlDomTextWriter.cs index 1ae073dea918..50b966954f08 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Dom/XmlDomTextWriter.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Dom/XmlDomTextWriter.cs @@ -10,7 +10,6 @@ namespace System.Xml { using System; using System.IO; using System.Text; - using System.Runtime.Versioning; // Represents a writer that will make it possible to work with prefixes even // if the namespace is not specified. @@ -19,9 +18,7 @@ internal class XmlDOMTextWriter : XmlTextWriter { public XmlDOMTextWriter( Stream w, Encoding encoding ) : base( w,encoding ) { } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + public XmlDOMTextWriter( String filename, Encoding encoding ) : base( filename,encoding ){ } diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Dom/XmlElement.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Dom/XmlElement.cs index dacc08245ad4..0c051bfd87bf 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Dom/XmlElement.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Dom/XmlElement.cs @@ -361,7 +361,7 @@ public virtual bool HasAttribute(string localName, string namespaceURI) { // Saves the current node to the specified XmlWriter. public override void WriteTo(XmlWriter w) { - if (GetType() == typeof(XmlElement)) { + if (this.GetType() == typeof(XmlElement)) { // Use the non-recursive version (for XmlElement only) WriteElementTo(w, this); } diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Dom/XmlNode.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Dom/XmlNode.cs index c3eb2784262a..e5d477854321 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Dom/XmlNode.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Dom/XmlNode.cs @@ -18,7 +18,7 @@ namespace System.Xml { // Represents a single node in the document. [DebuggerDisplay("{debuggerDisplayProxy}")] - public abstract class XmlNode : ICloneable, IEnumerable, IXPathNavigable { + public abstract class XmlNode : IEnumerable, IXPathNavigable { internal XmlNode parentNode; //this pointer is reused to save the userdata information, need to prevent internal user access the pointer directly. internal XmlNode () { @@ -752,10 +752,6 @@ public virtual XmlNode Clone() { return this.CloneNode(true); } - object ICloneable.Clone() { - return this.CloneNode(true); - } - // Provides a simple ForEach-style iteration over the // collection of nodes in this XmlNamedNodeMap. IEnumerator IEnumerable.GetEnumerator() { diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/HWStack.cs b/XmlWithCli/src/XmlWithCli/System/Xml/HWStack.cs index fd1d8c99cfae..88bc901fc202 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/HWStack.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/HWStack.cs @@ -17,7 +17,7 @@ namespace System.Xml { // so that next time Push() is called it simply returns the last // object that was already on the stack. - internal class HWStack : ICloneable { + internal class HWStack { internal HWStack(int GrowthRate) : this (GrowthRate, int.MaxValue) {} internal HWStack(int GrowthRate, int limit) { @@ -86,10 +86,6 @@ internal int Length { get { return this.used;} } - // - // ICloneable - // - private HWStack(object[] stack, int growthRate, int used, int size) { this.stack = stack; this.growthRate = growthRate; diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Resolvers/XmlPreloadedResolver.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Resolvers/XmlPreloadedResolver.cs index 1e59b2390e12..24a5fe9f84ce 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Resolvers/XmlPreloadedResolver.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Resolvers/XmlPreloadedResolver.cs @@ -15,7 +15,6 @@ using System.Reflection; using System.Diagnostics; using System.Collections.Generic; -using System.Runtime.Versioning; namespace System.Xml.Resolvers { @@ -167,10 +166,6 @@ public XmlPreloadedResolver(XmlResolver fallbackResolver, XmlKnownDtds preloaded } } -#if !SILVERLIGHT - [ResourceExposure(ResourceScope.Machine)] - [ResourceConsumption(ResourceScope.Machine)] -#endif public override Uri ResolveUri(Uri baseUri, string relativeUri) { // 1) special-case well-known public IDs // 2) To make FxCop happy we need to use StartsWith() overload that takes StringComparison -> diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/CodeGenerator.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/CodeGenerator.cs index 5ebdf1717f9a..cc628f8f6174 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/CodeGenerator.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/CodeGenerator.cs @@ -726,7 +726,7 @@ private static MethodInfo GetPropertyMethodFromBaseType(PropertyInfo propertyInf internal Type LoadMember(MemberInfo memberInfo) { Type memberType = null; - if (memberInfo.MemberType == MemberTypes.Field) { + if(memberInfo is FieldInfo) { FieldInfo fieldInfo = (FieldInfo)memberInfo; memberType = fieldInfo.FieldType; if (fieldInfo.IsStatic) { @@ -737,7 +737,7 @@ internal Type LoadMember(MemberInfo memberInfo) { } } else { - System.Diagnostics.Debug.Assert(memberInfo.MemberType == MemberTypes.Property); + System.Diagnostics.Debug.Assert(memberInfo is PropertyInfo); PropertyInfo property = (PropertyInfo)memberInfo; memberType = property.PropertyType; if (property != null) { @@ -758,7 +758,7 @@ internal Type LoadMember(MemberInfo memberInfo) { internal Type LoadMemberAddress(MemberInfo memberInfo) { Type memberType = null; - if (memberInfo.MemberType == MemberTypes.Field) { + if (memberInfo is FieldInfo) { FieldInfo fieldInfo = (FieldInfo)memberInfo; memberType = fieldInfo.FieldType; if (fieldInfo.IsStatic) { @@ -769,7 +769,7 @@ internal Type LoadMemberAddress(MemberInfo memberInfo) { } } else { - System.Diagnostics.Debug.Assert(memberInfo.MemberType == MemberTypes.Property); + System.Diagnostics.Debug.Assert(memberInfo is PropertyInfo); PropertyInfo property = (PropertyInfo)memberInfo; memberType = property.PropertyType; if (property != null) { @@ -793,7 +793,7 @@ internal Type LoadMemberAddress(MemberInfo memberInfo) { } internal void StoreMember(MemberInfo memberInfo) { - if (memberInfo.MemberType == MemberTypes.Field) { + if (memberInfo is FieldInfo) { FieldInfo fieldInfo = (FieldInfo)memberInfo; if (fieldInfo.IsStatic) { ilGen.Emit(OpCodes.Stsfld, fieldInfo); @@ -803,7 +803,7 @@ internal void StoreMember(MemberInfo memberInfo) { } } else { - System.Diagnostics.Debug.Assert(memberInfo.MemberType == MemberTypes.Property); + System.Diagnostics.Debug.Assert(memberInfo is PropertyInfo); PropertyInfo property = (PropertyInfo)memberInfo; if (property != null) { MethodInfo setMethod = property.GetSetMethod(true); diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/CodeIdentifier.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/CodeIdentifier.cs index b02095b91986..a62a655141a4 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/CodeIdentifier.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/CodeIdentifier.cs @@ -202,7 +202,7 @@ internal static string GetCSharpName(Type t) { } } - Type[] arguments = t.IsGenericType || t.GettyContainsGenericParameters ? t.GenericTypeArguments : new Type[0]; + Type[] arguments = t.IsGenericType || t.ContainsGenericParameters ? t.GenericTypeArguments : new Type[0]; GetCSharpName(t, arguments, 0, sb); for (int i = 0; i < rank; i++) { sb.Append("[]"); diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/Compilation.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/Compilation.cs index 125b33dca992..6a6e50b5650c 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/Compilation.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/Compilation.cs @@ -17,12 +17,10 @@ namespace System.Xml.Serialization { using System.Xml; using System.Threading; using System.Security; - using System.Security.Policy; using System.Xml.Serialization.Configuration; using System.Diagnostics; using System.CodeDom.Compiler; using System.Globalization; - using System.Runtime.Versioning; using System.Diagnostics.CodeAnalysis; internal class TempAssembly { @@ -144,8 +142,6 @@ internal void InitAssemblyMethods(XmlMapping[] xmlMappings) { /// // SxS: This method does not take any resource name and does not expose any resources to the caller. // It's OK to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] internal static Assembly LoadGeneratedAssembly(Type type, string defaultNamespace, out XmlSerializerImplementation contract) { Assembly serializer = null; contract = null; @@ -271,8 +267,6 @@ static bool IsSerializerVersionMatch(Assembly serializer, Type type, string defa // SxS: This method does not take any resource name and does not expose any resources to the caller. // It's OK to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] static string GenerateAssemblyId(Type type) { Module[] modules = type.GetTypeInfo().Assembly.GetModules(); ArrayList list = new ArrayList(); @@ -513,8 +507,6 @@ internal static Assembly GenerateRefEmitAssembly(XmlMapping[] xmlMappings, Type[ // SxS: This method does not take any resource name and does not expose any resources to the caller. // It's OK to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] static MethodInfo GetMethodFromType(Type type, string methodName, Assembly assembly) { MethodInfo method = type.GetMethod(methodName); if (method != null) diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/Compiler.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/Compiler.cs index 54f0c87765dd..b2bff8344754 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/Compiler.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/Compiler.cs @@ -17,19 +17,16 @@ namespace System.Xml.Serialization { using System.Security; using System.Diagnostics; using System.Security.Principal; - using System.Security.Policy; using System.Threading; using System.Xml.Serialization.Configuration; using System.Globalization; - using System.Runtime.Versioning; using System.Runtime.CompilerServices; internal class Compiler { bool debugEnabled = DiagnosticsSwitches.KeepTempFiles.Enabled; Hashtable imports = new Hashtable(); StringWriter writer = new StringWriter(CultureInfo.InvariantCulture); - - [ResourceExposure(ResourceScope.Machine)] + protected string[] Imports { get { string[] array = new string[imports.Values.Count]; @@ -40,8 +37,6 @@ protected string[] Imports { // SxS: This method does not take any resource name and does not expose any resources to the caller. // It's OK to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] internal void AddImport(Type type, Hashtable types) { if (type == null) return; @@ -97,8 +92,6 @@ internal void AddImport(Type type, Hashtable types) { // SxS: This method does not take any resource name and does not expose any resources to the caller. // It's OK to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] internal void AddImport(Assembly assembly) { TempAssembly.FileIOPermission.Assert(); imports[assembly] = assembly.Location; @@ -109,9 +102,7 @@ internal TextWriter Source { } internal void Close() { } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + internal static string GetTempAssemblyPath(string baseDir, Assembly assembly, string defaultNamespace) { if (assembly.IsDynamic) { throw new InvalidOperationException(string.Format(Res.XmlPregenAssemblyDynamic)); @@ -153,8 +144,6 @@ internal static string GetTempAssemblyName(AssemblyName parent, string ns) { // SxS: This method does not take any resource name and does not expose any resources to the caller. // It's OK to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] internal Assembly Compile(Assembly parent, string ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence) { CodeDomProvider codeProvider = new Microsoft.CSharp.CSharpCodeProvider(); CompilerParameters parameters = xmlParameters.CodeDomParameters; diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/Models.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/Models.cs index 350ceaefb2c0..d5a5946d0202 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/Models.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/Models.cs @@ -134,13 +134,13 @@ internal MemberInfo[] GetMemberInfos() { int cMember = 0; // first copy all non-property members over for (int i = 0; i < members.Length; i++) { - if ((members[i].MemberType & MemberTypes.Property) == 0) { + if ((members[i] is PropertyInfo) == false) { fieldsAndProps[cMember++] = members[i]; } } // now copy all property members over for (int i = 0; i < members.Length; i++) { - if ((members[i].MemberType & MemberTypes.Property) != 0) { + if (members[i] is PropertyInfo) { fieldsAndProps[cMember++] = members[i]; } } diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/SoapCodeExporter.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/SoapCodeExporter.cs index 69cb1f122b3e..59b992855b46 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/SoapCodeExporter.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/SoapCodeExporter.cs @@ -101,9 +101,6 @@ void ExportType(TypeMapping mapping) { // Add [GeneratedCodeAttribute(Tool=.., Version=..)] codeClass.CustomAttributes.Add(GeneratedCodeAttribute); - // Add [SerializableAttribute] - codeClass.CustomAttributes.Add(new CodeAttributeDeclaration(typeof(SerializableAttribute).FullName)); - if (!codeClass.IsEnum) { // Add [DebuggerStepThrough] codeClass.CustomAttributes.Add(new CodeAttributeDeclaration(typeof(DebuggerStepThroughAttribute).FullName)); diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/SoapReflectionImporter.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/SoapReflectionImporter.cs index 07f60b52ebcd..4233308a8168 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/SoapReflectionImporter.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/SoapReflectionImporter.cs @@ -372,7 +372,7 @@ bool InitializeStructMembers(StructMapping mapping, StructModel model, Recursion } ArrayList members = new ArrayList(); foreach (MemberInfo memberInfo in model.GetMemberInfos()) { - if ((memberInfo.MemberType & (MemberTypes.Field | MemberTypes.Property)) == 0) + if ((memberInfo is FieldInfo | memberInfo is PropertyInfo) == false) continue; SoapAttributes memberAttrs = GetAttributes(memberInfo); if (memberAttrs.SoapIgnore) continue; diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/Types.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/Types.cs index 160c9aea7e43..513322b837ca 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/Types.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/Types.cs @@ -955,7 +955,7 @@ static void GetSettableMembers(StructMapping mapping, ArrayList list) { if(mapping.Members != null) { foreach (MemberMapping memberMapping in mapping.Members) { MemberInfo memberInfo = memberMapping.MemberInfo; - if(memberInfo != null && memberInfo.MemberType == MemberTypes.Property) { + if(memberInfo != null && (memberInfo is PropertyInfo)) { PropertyInfo propertyInfo = memberInfo as PropertyInfo; if (propertyInfo != null && !CanWriteProperty(propertyInfo, memberMapping.TypeDesc)) { throw new InvalidOperationException(string.Format(Res.XmlReadOnlyPropertyError, propertyInfo.DeclaringType, propertyInfo.Name)); diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlCodeExporter.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlCodeExporter.cs index 778fed8da63d..f0849eba83ea 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlCodeExporter.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlCodeExporter.cs @@ -137,9 +137,6 @@ void ExportType(TypeMapping mapping, string name, string ns, ElementAccessor roo // Add [GeneratedCodeAttribute(Tool=.., Version=..)] codeClass.CustomAttributes.Add(GeneratedCodeAttribute); - // Add [SerializableAttribute] - codeClass.CustomAttributes.Add(new CodeAttributeDeclaration(typeof(SerializableAttribute).FullName)); - if (!codeClass.IsEnum) { // Add [DebuggerStepThrough] codeClass.CustomAttributes.Add(new CodeAttributeDeclaration(typeof(DebuggerStepThroughAttribute).FullName)); diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlReflectionImporter.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlReflectionImporter.cs index 12f18b11c38b..39615aee6a9e 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlReflectionImporter.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlReflectionImporter.cs @@ -744,7 +744,7 @@ bool InitializeStructMembers(StructMapping mapping, StructModel model, bool open bool isSequence = false; foreach (MemberInfo memberInfo in model.GetMemberInfos()) { - if ((memberInfo.MemberType & (MemberTypes.Field | MemberTypes.Property)) == 0) + if ((memberInfo is FieldInfo | memberInfo is PropertyInfo) == false) continue; XmlAttributes memberAttrs = GetAttributes(memberInfo); if (memberAttrs.XmlIgnore) continue; diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSchemas.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSchemas.cs index 7e05534f9bab..eb9cc2cee18f 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSchemas.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSchemas.cs @@ -17,7 +17,6 @@ namespace System.Xml.Serialization { using System.Xml.Schema; using System.Diagnostics; using System.Threading; - using System.Security.Policy; using System.Security; using System.Net; diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSerializationILGen.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSerializationILGen.cs index 523e657269b9..65d335a3ffee 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSerializationILGen.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSerializationILGen.cs @@ -568,7 +568,7 @@ internal void ILGenLoad(string source, Type type) { MemberInfo memInfo = memberInfos[source.Substring(3)]; ilg.LoadMember(ilg.GetVariable("o"), memInfo); if (type != null) { - Type memType = (memInfo.MemberType == MemberTypes.Field) ? ((FieldInfo)memInfo).FieldType : ((PropertyInfo)memInfo).PropertyType; + Type memType = (memInfo is FieldInfo) ? ((FieldInfo)memInfo).FieldType : ((PropertyInfo)memInfo).PropertyType; ilg.ConvertValue(memType, type); } } diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSerializationReaderILGen.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSerializationReaderILGen.cs index be31908fbf0f..e3f51d45ba38 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSerializationReaderILGen.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSerializationReaderILGen.cs @@ -2807,7 +2807,7 @@ void WriteSourceEnd(string source, Type elementType, Type stackType) { if (source.StartsWith("o.@", StringComparison.Ordinal)) { Debug.Assert(memberInfos.ContainsKey(source.Substring(3))); MemberInfo memInfo = memberInfos[source.Substring(3)]; - ilg.ConvertValue(stackType, memInfo.MemberType == MemberTypes.Field ? ((FieldInfo)memInfo).FieldType : ((PropertyInfo)memInfo).PropertyType); + ilg.ConvertValue(stackType, memInfo is FieldInfo ? ((FieldInfo)memInfo).FieldType : ((PropertyInfo)memInfo).PropertyType); ilg.StoreMember(memInfo); return; } diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSerializationWriter.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSerializationWriter.cs index ab720aea3b5e..decb494b4f86 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSerializationWriter.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSerializationWriter.cs @@ -19,7 +19,6 @@ namespace System.Xml.Serialization { using System.Globalization; using System.Text; using System.Threading; - using System.Runtime.Versioning; /// /// @@ -3233,8 +3232,6 @@ static FileIOPermission UnrestrictedFileIOPermission { // SxS: This method does not take any resource name and does not expose any resources to the caller. // It's OK to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] internal static bool IsTypeDynamic(Type type) { object oIsTypeDynamic = tableIsTypeDynamic[type]; if (oIsTypeDynamic == null) { @@ -3476,8 +3473,7 @@ string WriteAssemblyInfo(Type type){ string WriteMemberInfo(Type type, string escapedName, string typeVariable, string memberName){ MemberInfo[] memberInfos = type.GetMember(memberName); for (int i = 0; i < memberInfos.Length; i++) { - MemberTypes memberType = memberInfos[i].MemberType; - if (memberType == MemberTypes.Property){ + if (memberInfos[i] is PropertyInfo){ string propVariable = GenerateVariableName("prop", memberName); writer.Write("static XSPropInfo "+propVariable+" = new XSPropInfo("+typeVariable+", "); WriteQuotedCSharpString(memberName); @@ -3485,7 +3481,7 @@ string WriteMemberInfo(Type type, string escapedName, string typeVariable, strin reflectionVariables.Add(memberName+":"+escapedName, propVariable); return propVariable; } - else if (memberType == MemberTypes.Field){ + else if (memberInfos[i] is FieldInfo){ string fieldVariable = GenerateVariableName("field", memberName); writer.Write("static XSFieldInfo "+fieldVariable+" = new XSFieldInfo("+typeVariable+", "); WriteQuotedCSharpString(memberName); diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSerializer.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSerializer.cs index c732fb56808e..3d73a5887c18 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSerializer.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSerializer.cs @@ -16,11 +16,9 @@ namespace System.Xml.Serialization { using System.Threading; using System.Globalization; using System.Security; - using System.Security.Policy; using System.Xml.Serialization.Configuration; using System.Diagnostics; using System.CodeDom.Compiler; - using System.Runtime.Versioning; /// /// @@ -583,8 +581,6 @@ public static Assembly GenerateSerializer(Type[] types, XmlMapping[] mappings) { /// // SxS: This method does not take any resource name and does not expose any resources to the caller. // It's OK to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] public static Assembly GenerateSerializer(Type[] types, XmlMapping[] mappings, CompilerParameters parameters) { if (types == null || types.Length == 0) return null; diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSerializerFactory.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSerializerFactory.cs index 222bacd94471..88fddc892330 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSerializerFactory.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Serialization/XmlSerializerFactory.cs @@ -15,7 +15,6 @@ namespace System.Xml.Serialization { using System.Text; using System.Threading; using System.Globalization; - using System.Security.Policy; using System.Xml.Serialization.Configuration; using System.Diagnostics; using System.CodeDom.Compiler; diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/XPath/XPathDocument.cs b/XmlWithCli/src/XmlWithCli/System/Xml/XPath/XPathDocument.cs index 1072277a7945..2458f8ffa586 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/XPath/XPathDocument.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/XPath/XPathDocument.cs @@ -13,7 +13,6 @@ using MS.Internal.Xml.Cache; using System.Diagnostics; using System.Text; -using System.Runtime.Versioning; namespace System.Xml.XPath { @@ -108,16 +107,12 @@ public XPathDocument(Stream stream) { /// /// Create a new document and load the content from the Uri. /// - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] public XPathDocument(string uri) : this(uri, XmlSpace.Default) { } /// /// Create a new document and load the content from the Uri, with whitespace handling controlled according to "space". /// - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] public XPathDocument(string uri, XmlSpace space) { XmlTextReaderImpl reader = SetupReader(new XmlTextReaderImpl(uri)); diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/XPath/XPathException.cs b/XmlWithCli/src/XmlWithCli/System/Xml/XPath/XPathException.cs index c3eb423ceb57..fd8830417b37 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/XPath/XPathException.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/XPath/XPathException.cs @@ -9,12 +9,10 @@ namespace System.Xml.XPath { using System; using System.IO; using System.Resources; - using System.Runtime.Serialization; using System.Diagnostics; // Represents the exception that is thrown when there is error processing an // XPath expression. - [Serializable] public class XPathException : Exception { // we need to keep this members for V1 serialization compatibility string res; @@ -24,35 +22,6 @@ public class XPathException : Exception { // message == null for created V2 exceptions; the exception message is stored in Exception._message string message; - protected XPathException(SerializationInfo info, StreamingContext context) : base(info, context) { - res = (string ) info.GetValue("res" , typeof(string )); - args = (string[]) info.GetValue("args", typeof(string[])); - - // deserialize optional members - string version = null; - foreach ( SerializationEntry e in info ) { - if ( e.Name == "version" ) { - version = (string)e.Value; - } - } - - if (version == null) { - // deserializing V1 exception - message = CreateMessage(res, args); - } - else { - // deserializing V2 or higher exception -> exception message is serialized by the base class (Exception._message) - message = null; - } - } - - public override void GetObjectData(SerializationInfo info, StreamingContext context) { - base.GetObjectData(info, context); - info.AddValue("res" , res ); - info.AddValue("args", args); - info.AddValue("version", "2.0"); - } - public XPathException() : this (string.Empty, (Exception) null) {} public XPathException(string message) : this (message, (Exception) null) {} diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/XPath/XPathNavigator.cs b/XmlWithCli/src/XmlWithCli/System/Xml/XPath/XPathNavigator.cs index a5f26f5456e9..12f76a1b7111 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/XPath/XPathNavigator.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/XPath/XPathNavigator.cs @@ -14,7 +14,6 @@ using System.Diagnostics; using System.Diagnostics.Contracts; using System.Security; -using System.Security.Policy; using System.Text; using System.Xml; using MS.Internal.Xml.Cache; @@ -26,7 +25,7 @@ namespace System.Xml.XPath { #if CONTRACTS_FULL [ContractClass(typeof(XPathNavigatorContract))] #endif - public abstract class XPathNavigator : XPathItem, ICloneable, IXPathNavigable, IXmlNamespaceResolver { + public abstract class XPathNavigator : XPathItem, IXPathNavigable, IXmlNamespaceResolver { internal static readonly XPathNavigatorKeyComparer comparer = new XPathNavigatorKeyComparer(); //----------------------------------------------- @@ -333,14 +332,6 @@ public override object ValueAs(Type returnType, IXmlNamespaceResolver nsResolver return XmlUntypedConverter.Untyped.ChangeType(Value, returnType, nsResolver); } - //----------------------------------------------- - // ICloneable - //----------------------------------------------- - - object ICloneable.Clone() { - return Clone(); - } - //----------------------------------------------- // IXPathNavigable //----------------------------------------------- diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/XPath/XPathNodeIterator.cs b/XmlWithCli/src/XmlWithCli/System/Xml/XPath/XPathNodeIterator.cs index 6dc79a72f46b..db84f20a6fa0 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/XPath/XPathNodeIterator.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/XPath/XPathNodeIterator.cs @@ -12,11 +12,9 @@ namespace System.Xml.XPath { [DebuggerDisplay("Position={CurrentPosition}, Current={debuggerDisplayProxy}")] - public abstract class XPathNodeIterator : ICloneable, IEnumerable { + public abstract class XPathNodeIterator : IEnumerable { internal int count = -1; - object ICloneable.Clone() { return this.Clone(); } - public abstract XPathNodeIterator Clone(); public abstract bool MoveNext(); public abstract XPathNavigator Current { get; } diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/XmlDownloadManager.cs b/XmlWithCli/src/XmlWithCli/System/Xml/XmlDownloadManager.cs index dedccfdff3c9..0e21f650690f 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/XmlDownloadManager.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/XmlDownloadManager.cs @@ -13,7 +13,6 @@ namespace System.Xml { using System.Collections; using System.Net; using System.Net.Cache; - using System.Runtime.Versioning; // // XmlDownloadManager @@ -21,9 +20,7 @@ namespace System.Xml { internal partial class XmlDownloadManager { Hashtable connections; - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + internal Stream GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy) { if ( uri.Scheme == "file" ) { diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/XmlDownloadManagerAsync.cs b/XmlWithCli/src/XmlWithCli/System/Xml/XmlDownloadManagerAsync.cs index a71cc5b378a7..869dc4ca4447 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/XmlDownloadManagerAsync.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/XmlDownloadManagerAsync.cs @@ -7,16 +7,13 @@ namespace System.Xml { using System.Collections; using System.Net; using System.Net.Cache; - using System.Runtime.Versioning; using System.Threading.Tasks; // // XmlDownloadManager // internal partial class XmlDownloadManager { - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + internal Task GetStreamAsync(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy) { if (uri.Scheme == "file") { diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/XmlException.cs b/XmlWithCli/src/XmlWithCli/System/Xml/XmlException.cs index aacd242e675a..0e961abfeac4 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/XmlException.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/XmlException.cs @@ -13,75 +13,23 @@ namespace System.Xml { using System.Diagnostics; using System.Globalization; using System.Threading; -#if !SILVERLIGHT - using System.Runtime.Serialization; -#endif /// /// Returns detailed information about the last parse error, including the error /// number, line number, character position, and a text description. /// -#if !SILVERLIGHT - [Serializable] -#endif public class XmlException : Exception { string res; string[] args; // this field is not used, it's here just V1.1 serialization compatibility int lineNumber; int linePosition; -#if !SILVERLIGHT - [OptionalField] -#endif string sourceUri; // message != null for V1 exceptions deserialized in Whidbey // message == null for V2 or higher exceptions; the exception message is stored on the base class (Exception._message) string message; -#if !SILVERLIGHT - protected XmlException(SerializationInfo info, StreamingContext context) : base(info, context) { - res = (string) info.GetValue("res" , typeof(string)); - args = (string[])info.GetValue("args", typeof(string[])); - lineNumber = (int) info.GetValue("lineNumber", typeof(int)); - linePosition = (int) info.GetValue("linePosition", typeof(int)); - - // deserialize optional members - sourceUri = string.Empty; - string version = null; - foreach ( SerializationEntry e in info ) { - switch ( e.Name ) { - case "sourceUri": - sourceUri = (string)e.Value; - break; - case "version": - version = (string)e.Value; - break; - } - } - - if ( version == null ) { - // deserializing V1 exception - message = CreateMessage( res, args, lineNumber, linePosition ); - } - else { - // deserializing V2 or higher exception -> exception message is serialized by the base class (Exception._message) - message = null; - } - } - - [SecurityPermissionAttribute(SecurityAction.LinkDemand,SerializationFormatter=true)] - public override void GetObjectData(SerializationInfo info, StreamingContext context) { - base.GetObjectData(info, context); - info.AddValue("res", res); - info.AddValue("args", args); - info.AddValue("lineNumber", lineNumber); - info.AddValue("linePosition", linePosition); - info.AddValue("sourceUri", sourceUri); - info.AddValue("version", "2.0"); - } -#endif - //provided to meet the ECMA standards public XmlException() : this(null) { } @@ -298,8 +246,7 @@ internal static bool IsCatchableException(Exception e) { return !( e is OutOfMemoryException || e is ThreadInterruptedException || - e is NullReferenceException || - e is AccessViolationException + e is NullReferenceException ); } #endif diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/XmlQualifiedName.cs b/XmlWithCli/src/XmlWithCli/System/Xml/XmlQualifiedName.cs index 7bc4c189fb13..58e8e83a577d 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/XmlQualifiedName.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/XmlQualifiedName.cs @@ -18,9 +18,6 @@ namespace System.Xml { /// /// [To be supplied.] /// -#if !SILVERLIGHT - [Serializable] -#endif public class XmlQualifiedName { #if !SILVERLIGHT delegate int HashCodeOfStringDelegate(string s, int sLen, long additionalEntropy); @@ -29,9 +26,6 @@ public class XmlQualifiedName { string name; string ns; -#if !SILVERLIGHT - [NonSerialized] -#endif Int32 hash; /// diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/XmlResolver.cs b/XmlWithCli/src/XmlWithCli/System/Xml/XmlResolver.cs index 7957e9c31557..849264f18259 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/XmlResolver.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/XmlResolver.cs @@ -15,7 +15,6 @@ namespace System.Xml using System.Net; using System.Threading.Tasks; #endif - using System.Runtime.Versioning; /// /// @@ -40,10 +39,6 @@ public abstract Object GetEntity(Uri absoluteUri, /// /// [To be supplied.] /// -#if !SILVERLIGHT - [ResourceExposure(ResourceScope.Machine)] - [ResourceConsumption(ResourceScope.Machine)] -#endif public virtual Uri ResolveUri(Uri baseUri, string relativeUri) { if ( baseUri == null || ( !baseUri.IsAbsoluteUri && baseUri.OriginalString.Length == 0 ) ) { Uri uri = new Uri( relativeUri, UriKind.RelativeOrAbsolute ); diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/XmlSecureResolver.cs b/XmlWithCli/src/XmlWithCli/System/Xml/XmlSecureResolver.cs index 39c73406f19c..9988b64065c9 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/XmlSecureResolver.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/XmlSecureResolver.cs @@ -8,8 +8,6 @@ namespace System.Xml { using System.Net; using System.Security; - using System.Security.Policy; - using System.Runtime.Versioning; public partial class XmlSecureResolver : XmlResolver { XmlResolver resolver; @@ -33,8 +31,6 @@ public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToRe return resolver.GetEntity(absoluteUri, role, ofObjectToReturn); } - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] public override Uri ResolveUri(Uri baseUri, string relativeUri) { return resolver.ResolveUri(baseUri, relativeUri); } @@ -59,8 +55,7 @@ public static Evidence CreateEvidenceForUrl(string securityUrl) { } return evidence; } - - [Serializable] + private class UncDirectory : EvidenceBase, IIdentityPermissionFactory { private string uncDir; diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/XmlUrlResolver.cs b/XmlWithCli/src/XmlWithCli/System/Xml/XmlUrlResolver.cs index 4d3f55e80eb8..348df195341d 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/XmlUrlResolver.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/XmlUrlResolver.cs @@ -8,7 +8,6 @@ using System.Threading; using System.Net; using System.Net.Cache; -using System.Runtime.Versioning; namespace System.Xml { @@ -50,8 +49,6 @@ public RequestCachePolicy CachePolicy { // Resource resolution // Maps a URI to an Object containing the actual resource. - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] public override Object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn) { if (ofObjectToReturn == null || ofObjectToReturn == typeof(System.IO.Stream) || ofObjectToReturn == typeof(System.Object)) { return DownloadManager.GetStream(absoluteUri, _credentials, _proxy, _cachePolicy); @@ -61,8 +58,6 @@ public override Object GetEntity(Uri absoluteUri, string role, Type ofObjectToRe } } - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] public override Uri ResolveUri(Uri baseUri, string relativeUri){ return base.ResolveUri(baseUri, relativeUri); } diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/XmlUrlResolverAsync.cs b/XmlWithCli/src/XmlWithCli/System/Xml/XmlUrlResolverAsync.cs index bf9324eb1347..72d8823e6602 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/XmlUrlResolverAsync.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/XmlUrlResolverAsync.cs @@ -1,5 +1,4 @@ -using System.Runtime.Versioning; using System.Threading.Tasks; namespace System.Xml @@ -7,8 +6,6 @@ namespace System.Xml public partial class XmlUrlResolver : XmlResolver { // Maps a URI to an Object containing the actual resource. - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] public override async Task GetEntityAsync(Uri absoluteUri, string role, Type ofObjectToReturn) { if (ofObjectToReturn == null || ofObjectToReturn == typeof(System.IO.Stream) || ofObjectToReturn == typeof(System.Object)) { return await DownloadManager.GetStreamAsync(absoluteUri, _credentials, _proxy, _cachePolicy).ConfigureAwait(false); diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Xslt/XslCompiledTransform.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Xslt/XslCompiledTransform.cs index 516ce1361bb4..3a14ba1b7bd7 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Xslt/XslCompiledTransform.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Xslt/XslCompiledTransform.cs @@ -17,7 +17,6 @@ using System.Xml.Xsl.Qil; using System.Xml.Xsl.Runtime; using System.Xml.Xsl.Xslt; -using System.Runtime.Versioning; using System.Xml.XmlConfiguration; namespace System.Xml.Xsl { @@ -108,8 +107,6 @@ public TempFileCollection TemporaryFiles { // SxS: This method does not take any resource name and does not expose any resources to the caller. // It's OK to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] public void Load(XmlReader stylesheet) { Reset(); LoadInternal(stylesheet, XsltSettings.Default, XsltConfigSection.CreateDefaultResolver()); @@ -117,8 +114,6 @@ public void Load(XmlReader stylesheet) { // SxS: This method does not take any resource name and does not expose any resources to the caller. // It's OK to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] public void Load(XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver) { Reset(); LoadInternal(stylesheet, settings, stylesheetResolver); @@ -126,8 +121,6 @@ public void Load(XmlReader stylesheet, XsltSettings settings, XmlResolver styles // SxS: This method does not take any resource name and does not expose any resources to the caller. // It's OK to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] public void Load(IXPathNavigable stylesheet) { Reset(); LoadInternal(stylesheet, XsltSettings.Default, XsltConfigSection.CreateDefaultResolver()); @@ -135,15 +128,11 @@ public void Load(IXPathNavigable stylesheet) { // SxS: This method does not take any resource name and does not expose any resources to the caller. // It's OK to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] public void Load(IXPathNavigable stylesheet, XsltSettings settings, XmlResolver stylesheetResolver) { Reset(); LoadInternal(stylesheet, settings, stylesheetResolver); } - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] public void Load(string stylesheetUri) { Reset(); if (stylesheetUri == null) { @@ -151,9 +140,7 @@ public void Load(string stylesheetUri) { } LoadInternal(stylesheetUri, XsltSettings.Default, XsltConfigSection.CreateDefaultResolver()); } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + public void Load(string stylesheetUri, XsltSettings settings, XmlResolver stylesheetResolver) { Reset(); if (stylesheetUri == null) { @@ -161,9 +148,7 @@ public void Load(string stylesheetUri, XsltSettings settings, XmlResolver styles } LoadInternal(stylesheetUri, settings, stylesheetResolver); } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + private CompilerResults LoadInternal(object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver) { if (stylesheet == null) { throw new ArgumentNullException("stylesheet"); @@ -181,9 +166,7 @@ private CompilerResults LoadInternal(object stylesheet, XsltSettings settings, X } return this.compilerResults; } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + private void CompileXsltToQil(object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver) { this.compilerResults = new Compiler(settings, this.enableDebug, null).Compile(stylesheet, stylesheetResolver, out this.qil); } @@ -211,9 +194,7 @@ private void CompileQilToMsil(XsltSettings settings) { //------------------------------------------------ private static volatile ConstructorInfo GeneratedCodeCtor; - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + public static CompilerErrorCollection CompileToType(XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver, bool debug, TypeBuilder typeBuilder, string scriptAssemblyPath) { if (stylesheet == null) throw new ArgumentNullException("stylesheet"); @@ -392,8 +373,6 @@ public void Transform(XmlReader input, XsltArgumentList arguments, Stream result //------------------------------------------------ [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")] - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] public void Transform(string inputUri, XmlWriter results) { CheckArguments(inputUri, results); using (XmlReader reader = XmlReader.Create(inputUri, ReaderSettings)) { @@ -402,8 +381,6 @@ public void Transform(string inputUri, XmlWriter results) { } [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")] - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] public void Transform(string inputUri, XsltArgumentList arguments, XmlWriter results) { CheckArguments(inputUri, results); using (XmlReader reader = XmlReader.Create(inputUri, ReaderSettings)) { @@ -412,8 +389,6 @@ public void Transform(string inputUri, XsltArgumentList arguments, XmlWriter res } [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")] - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] public void Transform(string inputUri, XsltArgumentList arguments, TextWriter results) { CheckArguments(inputUri, results); using (XmlReader reader = XmlReader.Create(inputUri, ReaderSettings)) @@ -424,8 +399,6 @@ public void Transform(string inputUri, XsltArgumentList arguments, TextWriter re } [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")] - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] public void Transform(string inputUri, XsltArgumentList arguments, Stream results) { CheckArguments(inputUri, results); using (XmlReader reader = XmlReader.Create(inputUri, ReaderSettings)) @@ -436,8 +409,6 @@ public void Transform(string inputUri, XsltArgumentList arguments, Stream result } [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")] - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] public void Transform(string inputUri, string resultsFile) { if (inputUri == null) throw new ArgumentNullException("inputUri"); @@ -459,8 +430,6 @@ public void Transform(string inputUri, string resultsFile) { // SxS: This method does not take any resource name and does not expose any resources to the caller. // It's OK to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] public void Transform(XmlReader input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver) { CheckArguments(input, results); CheckCommand(); @@ -469,8 +438,6 @@ public void Transform(XmlReader input, XsltArgumentList arguments, XmlWriter res // SxS: This method does not take any resource name and does not expose any resources to the caller. // It's OK to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] public void Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver) { CheckArguments(input, results); CheckCommand(); @@ -506,9 +473,7 @@ private void CheckCommand() { //------------------------------------------------ // Test suites entry points //------------------------------------------------ - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + private QilExpression TestCompile(object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver) { Reset(); CompileXsltToQil(stylesheet, settings, stylesheetResolver); @@ -519,9 +484,7 @@ private void TestGenerate(XsltSettings settings) { Debug.Assert(qil != null, "You must compile to Qil first"); CompileQilToMsil(settings); } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + private void Transform(string inputUri, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver) { command.Execute(inputUri, documentResolver, arguments, results); } diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Xslt/XslCompiledTransformBase.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Xslt/XslCompiledTransformBase.cs index ad7200a04ffe..4ae6834809ec 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Xslt/XslCompiledTransformBase.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Xslt/XslCompiledTransformBase.cs @@ -51,7 +51,7 @@ protected XslCompiledTransformBase() { value = new XmlILCommand((ExecuteDelegate)delExec, new XmlQueryStaticData(data, (Type[])fldTypes.GetValue(/*this:*/null))); // Store the constructed command in the same field - System.Threading.Thread.MemoryBarrier(); + System.Threading.Interlocked.MemoryBarrier(); fldData.SetValue(/*this:*/null, value); } diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Xslt/XslTransform.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Xslt/XslTransform.cs index c4ee5754eb46..5aa398ed2db4 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Xslt/XslTransform.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Xslt/XslTransform.cs @@ -15,8 +15,6 @@ namespace System.Xml.Xsl { using MS.Internal.Xml.Cache; using System.Collections.Generic; using System.Xml.Xsl.XsltOld.Debugger; - using System.Security.Policy; - using System.Runtime.Versioning; using System.Xml.XmlConfiguration; [Obsolete("This class has been deprecated. Please use System.Xml.Xsl.XslCompiledTransform instead. http://go.microsoft.com/fwlink/?linkid=14202")] @@ -80,17 +78,13 @@ public void Load(XPathNavigator stylesheet, XmlResolver resolver) { } Compile(stylesheet, resolver, /*evidence:*/null); } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + public void Load(string url) { XmlTextReaderImpl tr = new XmlTextReaderImpl(url); Evidence evidence = XmlSecureResolver.CreateEvidenceForUrl(tr.BaseURI); // We should ask BaseURI before we start reading because it's changing with each node Compile(Compiler.LoadDocument(tr).CreateNavigator(), XsltConfigSection.CreateDefaultResolver(), evidence); } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + public void Load(string url, XmlResolver resolver) { XmlTextReaderImpl tr = new XmlTextReaderImpl(url); { tr.XmlResolver = resolver; @@ -227,9 +221,7 @@ public void Transform(IXPathNavigable input, XsltArgumentList args, XmlWriter ou } Transform(input.CreateNavigator(), args, output, _DocumentResolver); } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + public void Transform(String inputfile, String outputfile, XmlResolver resolver) { FileStream fs = null; try { @@ -240,13 +232,11 @@ public void Transform(String inputfile, String outputfile, XmlResolver resolver) } finally { if (fs != null) { - fs.Close(); + fs.Dispose(); } } } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + public void Transform(String inputfile, String outputfile) { Transform(inputfile, outputfile, _DocumentResolver); } diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/Xslt/XsltException.cs b/XmlWithCli/src/XmlWithCli/System/Xml/Xslt/XsltException.cs index 424d470c6ae9..bde14abafa2c 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/Xslt/XsltException.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/Xslt/XsltException.cs @@ -7,13 +7,11 @@ using System.Globalization; using System.Resources; -using System.Runtime.Serialization; using System.Xml.XPath; namespace System.Xml.Xsl { using Res = System.Xml.Utils.Res; - - [Serializable] + public class XsltException : Exception { string res; string[] args; @@ -25,42 +23,6 @@ public class XsltException : Exception { // message == null for created V2 exceptions; the exception message is stored in Exception._message string message; - protected XsltException(SerializationInfo info, StreamingContext context) : base(info, context) { - res = (string) info.GetValue("res" , typeof(string )); - args = (string[]) info.GetValue("args" , typeof(string[] )); - sourceUri = (string) info.GetValue("sourceUri" , typeof(string )); - lineNumber = (int) info.GetValue("lineNumber" , typeof(int )); - linePosition = (int) info.GetValue("linePosition", typeof(int )); - - // deserialize optional members - string version = null; - foreach ( SerializationEntry e in info ) { - if ( e.Name == "version" ) { - version = (string)e.Value; - } - } - - if (version == null) { - // deserializing V1 exception - message = CreateMessage(res, args, sourceUri, lineNumber, linePosition); - } - else { - // deserializing V2 or higher exception -> exception message is serialized by the base class (Exception._message) - message = null; - } - } - - [SecurityPermissionAttribute(SecurityAction.LinkDemand,SerializationFormatter=true)] - public override void GetObjectData(SerializationInfo info, StreamingContext context) { - base.GetObjectData(info, context); - info.AddValue("res" , res ); - info.AddValue("args" , args ); - info.AddValue("sourceUri" , sourceUri ); - info.AddValue("lineNumber" , lineNumber ); - info.AddValue("linePosition", linePosition); - info.AddValue("version" , "2.0"); - } - public XsltException() : this (string.Empty, (Exception) null) {} public XsltException(String message) : this (message, (Exception) null) {} @@ -126,17 +88,9 @@ private static string FormatMessage(string key, params string[] args) { return message; } } - - [Serializable] + public class XsltCompileException : XsltException { - protected XsltCompileException(SerializationInfo info, StreamingContext context) : base(info, context) {} - - [SecurityPermissionAttribute(SecurityAction.LinkDemand,SerializationFormatter=true)] - public override void GetObjectData(SerializationInfo info, StreamingContext context) { - base.GetObjectData(info, context); - } - public XsltCompileException() : base() {} public XsltCompileException(String message) : base (message) {} diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/schema/Inference/XmlSchemaInferenceException.cs b/XmlWithCli/src/XmlWithCli/System/Xml/schema/Inference/XmlSchemaInferenceException.cs index 9f5a080da6e2..3ca5b19d0e8c 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/schema/Inference/XmlSchemaInferenceException.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/schema/Inference/XmlSchemaInferenceException.cs @@ -11,22 +11,20 @@ namespace System.Xml.Schema using System; using System.IO; using System.Resources; - using System.Runtime.Serialization; using System.Text; using System.Diagnostics; using System.Globalization; - - [Serializable] + public class XmlSchemaInferenceException : XmlSchemaException { - protected XmlSchemaInferenceException(SerializationInfo info, StreamingContext context) : base(info, context){} + protected XmlSchemaInferenceException(StreamingContext context) : base(context){} - public override void GetObjectData(SerializationInfo info, StreamingContext context) + public override void GetObjectData(StreamingContext context) { - base.GetObjectData(info, context); + base.GetObjectData(context); } diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/schema/Preprocessor.cs b/XmlWithCli/src/XmlWithCli/System/Xml/schema/Preprocessor.cs index 03f6e9565afc..dcc6db135dd2 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/schema/Preprocessor.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/schema/Preprocessor.cs @@ -12,7 +12,6 @@ namespace System.Xml.Schema { using System.Threading; using System.Diagnostics; using System.Collections.Generic; - using System.Runtime.Versioning; internal enum Compositor { Root, @@ -233,8 +232,6 @@ private void BuildSchemaList(XmlSchema schema) { // SxS: This method uses resource names read from source document and does not expose any resources to the caller. // It's OK to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] private void LoadExternals(XmlSchema schema) { if (schema.IsProcessing) { return; @@ -1733,9 +1730,7 @@ private void ValidateQNameAttribute(XmlSchemaObject xso, string attributeName, X SendValidationEvent(Res.Sch_InvalidAttribute, new string[] {attributeName, ex.Message}, ex, xso); } } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + private Uri ResolveSchemaLocationUri(XmlSchema enclosingSchema, string location) { if (location.Length == 0) { return null; diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/schema/SchemaCollectionPreprocessor.cs b/XmlWithCli/src/XmlWithCli/System/Xml/schema/SchemaCollectionPreprocessor.cs index 633133da7afa..003153b3a002 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/schema/SchemaCollectionPreprocessor.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/schema/SchemaCollectionPreprocessor.cs @@ -11,7 +11,6 @@ namespace System.Xml.Schema { using System.Collections.Generic; using System.IO; using System.Diagnostics; - using System.Runtime.Versioning; #pragma warning disable 618 internal sealed class SchemaCollectionPreprocessor : BaseProcessor { @@ -115,8 +114,6 @@ internal XmlResolver XmlResolver { // SxS: This method reads resource names from the source documents and does not return any resources to the caller // It's fine to suppress the SxS warning - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] private void LoadExternals(XmlSchema schema, XmlSchemaCollection xsc) { if (schema.IsProcessing) { return; @@ -1427,9 +1424,7 @@ private void PreprocessAnnotation(XmlSchemaObject schemaObject) { } } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + private Uri ResolveSchemaLocationUri(XmlSchema enclosingSchema, string location) { try { return xmlResolver.ResolveUri(enclosingSchema.BaseUri, location); diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/schema/XdrBuilder.cs b/XmlWithCli/src/XmlWithCli/System/Xml/schema/XdrBuilder.cs index 03997aa69bd3..09082b3d08a7 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/schema/XdrBuilder.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/schema/XdrBuilder.cs @@ -13,7 +13,6 @@ namespace System.Xml.Schema { using System.Diagnostics; using System.ComponentModel; using System.Globalization; - using System.Runtime.Versioning; /* * The XdrBuilder class parses the XDR Schema and @@ -425,9 +424,7 @@ internal override bool ProcessElement(string prefix, string name, string ns) { } // SxS: This method processes attribute from the source document and does not expose any resources to the caller - // It is fine to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] + // It is fine to suppress the SxS warning. internal override void ProcessAttribute(string prefix, string name, string ns, string value) { XmlQualifiedName qname = new XmlQualifiedName(name, XmlSchemaDatatype.XdrCanonizeUri(ns, _NameTable, _SchemaNames)); for (int i = 0; i < _CurState._Attributes.Length; i++) { @@ -474,9 +471,7 @@ internal XmlResolver XmlResolver { xmlResolver = value; } } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + private bool LoadSchema(string uri) { if (xmlResolver == null) { return false; diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlAtomicValue.cs b/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlAtomicValue.cs index 595d129c0acd..6c30880e1fb1 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlAtomicValue.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlAtomicValue.cs @@ -17,7 +17,7 @@ namespace System.Xml.Schema { /// This class contains a (CLR Object, XmlType) pair that represents an instance of an Xml atomic value. /// It is optimized to avoid boxing. /// - public sealed class XmlAtomicValue : XPathItem, ICloneable { + public sealed class XmlAtomicValue : XPathItem { private XmlSchemaType xmlType; private object objVal; private TypeCode clrType; @@ -147,19 +147,6 @@ public XmlAtomicValue Clone() { return this; } - - //----------------------------------------------- - // ICloneable methods - //----------------------------------------------- - - /// - /// Since XmlAtomicValue is immutable, clone simply returns this. - /// - object ICloneable.Clone() { - return this; - } - - //----------------------------------------------- // XPathItem methods //----------------------------------------------- diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlSchemaCollection.cs b/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlSchemaCollection.cs index d104f4c07e77..44dd8b16dba7 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlSchemaCollection.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlSchemaCollection.cs @@ -11,7 +11,6 @@ namespace System.Xml.Schema { using System.Threading; using System.Collections; using System.Xml.Schema; - using System.Runtime.Versioning; /// @@ -29,7 +28,7 @@ public sealed class XmlSchemaCollection: ICollection { private Hashtable collection; private XmlNameTable nameTable; private SchemaNames schemaNames; - private ReaderWriterLock wLock; + private ReaderWriterLockSlim wLock; private int timeout = Timeout.Infinite; private bool isThreadSafe = true; private ValidationEventHandler validationEventHandler = null; @@ -57,7 +56,7 @@ public XmlSchemaCollection(XmlNameTable nametable) { xmlResolver = System.Xml.XmlConfiguration.XmlReaderSection.CreateDefaultResolver(); isThreadSafe = true; if (isThreadSafe) { - wLock = new ReaderWriterLock(); + wLock = new ReaderWriterLockSlim(); } } @@ -98,8 +97,6 @@ internal XmlResolver XmlResolver /// If the given schema references other namespaces, the schemas for those other /// namespaces are NOT automatically loaded. /// - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] public XmlSchema Add(string ns, string uri) { if (uri == null || uri.Length == 0) throw new ArgumentNullException("uri"); @@ -335,7 +332,7 @@ private XmlSchema Add(string ns, SchemaInfo schemaInfo, XmlSchema schema, bool c private void Add(string ns, XmlSchemaCollectionNode node) { if (isThreadSafe) - wLock.AcquireWriterLock(timeout); + wLock.TryEnterWriteLock(timeout); try { if (collection[ns] != null) collection.Remove(ns); @@ -343,7 +340,7 @@ private void Add(string ns, XmlSchemaCollectionNode node) { } finally { if (isThreadSafe) - wLock.ReleaseWriterLock(); + wLock.ExitWriteLock(); } } diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlSchemaException.cs b/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlSchemaException.cs index 8fa89250d550..71b29076d232 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlSchemaException.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlSchemaException.cs @@ -10,12 +10,10 @@ namespace System.Xml.Schema { using System.IO; using System.Text; using System.Resources; - using System.Runtime.Serialization; using System.Globalization; using System.Diagnostics; /// - [Serializable] public class XmlSchemaException : Exception { string res; string[] args; @@ -23,51 +21,11 @@ public class XmlSchemaException : Exception { int lineNumber; int linePosition; - [NonSerialized] XmlSchemaObject sourceSchemaObject; // message != null for V1 exceptions deserialized in Whidbey // message == null for V2 or higher exceptions; the exception message is stored on the base class (Exception._message) string message; - - /// - protected XmlSchemaException(SerializationInfo info, StreamingContext context) : base(info, context) { - res = (string) info.GetValue("res" , typeof(string)); - args = (string[]) info.GetValue("args", typeof(string[])); - sourceUri = (string) info.GetValue("sourceUri", typeof(string)); - lineNumber = (int) info.GetValue("lineNumber", typeof(int)); - linePosition = (int) info.GetValue("linePosition", typeof(int)); - - // deserialize optional members - string version = null; - foreach ( SerializationEntry e in info ) { - if ( e.Name == "version" ) { - version = (string)e.Value; - } - } - - if ( version == null ) { - // deserializing V1 exception - message = CreateMessage( res, args ); - } - else { - // deserializing V2 or higher exception -> exception message is serialized by the base class (Exception._message) - message = null; - } - } - - - /// - public override void GetObjectData(SerializationInfo info, StreamingContext context) { - base.GetObjectData(info, context); - info.AddValue("res", res); - info.AddValue("args", args); - info.AddValue("sourceUri", sourceUri); - info.AddValue("lineNumber", lineNumber); - info.AddValue("linePosition", linePosition); - info.AddValue("version", "2.0"); - } - /// public XmlSchemaException() : this(null) { diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlSchemaSet.cs b/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlSchemaSet.cs index 6311e1120b52..d45c7540be94 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlSchemaSet.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlSchemaSet.cs @@ -8,7 +8,6 @@ using System.Collections; using System.Threading; using System.Collections.Generic; -using System.Runtime.Versioning; namespace System.Xml.Schema { #if SILVERLIGHT @@ -274,8 +273,6 @@ internal XmlSchemaObjectTable TypeExtensions { /// If the given schema references other namespaces, the schemas for those other /// namespaces are NOT automatically loaded. /// - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] public XmlSchema Add(String targetNamespace, String schemaUri) { if (schemaUri == null || schemaUri.Length == 0) { throw new ArgumentNullException("schemaUri"); diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlSchemaValidationException.cs b/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlSchemaValidationException.cs index 39058b8276d9..9164b44ef65c 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlSchemaValidationException.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlSchemaValidationException.cs @@ -10,23 +10,12 @@ namespace System.Xml.Schema { using System.IO; using System.Text; using System.Resources; - using System.Runtime.Serialization; using System.Diagnostics; /// - [Serializable] public class XmlSchemaValidationException : XmlSchemaException { private Object sourceNodeObject; - - /// - protected XmlSchemaValidationException(SerializationInfo info, StreamingContext context) : base(info, context) {} - - - /// - public override void GetObjectData(SerializationInfo info, StreamingContext context) { - base.GetObjectData(info, context); - } /// public XmlSchemaValidationException() : base(null) { diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlSchemaValidator.cs b/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlSchemaValidator.cs index 035cbb751812..f49c4eb601bd 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlSchemaValidator.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/schema/XmlSchemaValidator.cs @@ -15,7 +15,6 @@ using System.Xml.Schema; using System.Xml.XPath; using System.Threading; -using System.Runtime.Versioning; namespace System.Xml.Schema { @@ -358,14 +357,10 @@ public void Initialize(XmlSchemaObject partialValidationType) { // SxS: This method passes null as resource names and does not expose any resources to the caller. // It's OK to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] public void ValidateElement(string localName, string namespaceUri, XmlSchemaInfo schemaInfo) { ValidateElement(localName, namespaceUri, schemaInfo, null, null, null, null); } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + public void ValidateElement(string localName, string namespaceUri, XmlSchemaInfo schemaInfo, string xsiType, string xsiNil, string xsiSchemaLocation, string xsiNoNamespaceSchemaLocation) { if (localName == null) { throw new ArgumentNullException("localName"); @@ -1080,9 +1075,7 @@ private object InternalValidateEndElement(XmlSchemaInfo schemaInfo, object typed Pop(); return typedValue; } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + private void ProcessSchemaLocations(string xsiSchemaLocation, string xsiNoNamespaceSchemaLocation) { bool compile = false; if (xsiNoNamespaceSchemaLocation != null) { @@ -1541,9 +1534,7 @@ internal object CheckMixedValueConstraint(string elementValue) { return elementValue; } } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + private void LoadSchema(string uri, string url) { Debug.Assert(xmlResolver != null); XmlReader Reader = null; diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/schema/xdrvalidator.cs b/XmlWithCli/src/XmlWithCli/System/Xml/schema/xdrvalidator.cs index 7a5af3313ee3..d7e671e869b8 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/schema/xdrvalidator.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/schema/xdrvalidator.cs @@ -12,7 +12,6 @@ namespace System.Xml.Schema { using System.Collections; using System.Diagnostics; using System.Globalization; - using System.Runtime.Versioning; #pragma warning disable 618 internal sealed class XdrValidator : BaseValidator { @@ -159,9 +158,7 @@ private void ValidateEndElement() { } // SxS: This method processes resource names read from the source document and does not expose - // any resources to the caller. It is fine to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] + // any resources to the caller. It is fine to suppress the SxS warning. private SchemaElementDecl ThoroughGetElementDecl() { if (reader.Depth == 0) { LoadSchema(string.Empty); @@ -267,9 +264,7 @@ private void ValidateEndStartElement() { textValue.Length = 0; } } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + private void LoadSchemaFromLocation(string uri) { // is x-schema if (!XdrBuilder.IsXdrSchema(uri)) { @@ -305,9 +300,7 @@ private void LoadSchemaFromLocation(string uri) { SchemaCollection.Add(uri, xdrSchema, null, false); } } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + private void LoadSchema(string uri) { if (this.schemaInfo.TargetNamespaces.ContainsKey(uri)) { return; diff --git a/XmlWithCli/src/XmlWithCli/System/Xml/schema/xsdvalidator.cs b/XmlWithCli/src/XmlWithCli/System/Xml/schema/xsdvalidator.cs index e86576a382c8..eaf7fcb920dc 100644 --- a/XmlWithCli/src/XmlWithCli/System/Xml/schema/xsdvalidator.cs +++ b/XmlWithCli/src/XmlWithCli/System/Xml/schema/xsdvalidator.cs @@ -14,7 +14,6 @@ namespace System.Xml.Schema { using System.Diagnostics; using System.Xml.Schema; using System.Xml.XPath; - using System.Runtime.Versioning; #pragma warning disable 618 internal sealed class XsdValidator : BaseValidator { @@ -218,8 +217,6 @@ private void ProcessElement(object particle) { // SxS: This method processes attributes read from source document and does not expose any resources. // It's OK to suppress the SxS warning. - [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] - [ResourceExposure(ResourceScope.None)] private void ProcessXsiAttributes(out XmlQualifiedName xsiType, out string xsiNil) { string[] xsiSchemaLocation = null; string xsiNoNamespaceSchemaLocation = null; @@ -470,9 +467,7 @@ private void ValidateEndStartElement() { } } - - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] + private void LoadSchemaFromLocation(string uri, string url) { XmlReader reader = null; @@ -516,8 +511,6 @@ private void LoadSchemaFromLocation(string uri, string url) { } } - [ResourceConsumption(ResourceScope.Machine)] - [ResourceExposure(ResourceScope.Machine)] private void LoadSchema(string uri, string url) { if (this.XmlResolver == null) { return; diff --git a/XmlWithCli/src/XmlWithCli/Workarounds/HResults.cs b/XmlWithCli/src/XmlWithCli/Workarounds/HResults.cs new file mode 100644 index 000000000000..6aeb83278aed --- /dev/null +++ b/XmlWithCli/src/XmlWithCli/Workarounds/HResults.cs @@ -0,0 +1,109 @@ +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +//------------------------------------------------------------------------------ + +/* +These HRESULTs are used for mapping managed exceptions to COM error codes +and vice versa through COM Interop. For background on COM error codes see +http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/error_9td2.asp. + +FACILITY_URT is defined as 0x13 (0x8013xxxx). The facility range is reserved +for the .NET Framework SDK teams. + +Within that range, the following subranges have been allocated for different +feature areas: + +0x10yy for Execution Engine +0x11yy for Metadata, TypeLib Export, and CLDB +0x12yy for MetaData Validator +0x13yy for Debugger and Profiler errors +0x14yy for Security +0x15yy for BCL +0x1600 - 0x161F for Reflection +0x1620 - 0x163F for System.IO +0x1640 - 0x165F for Security +0x1660 - 0x16FF for BCL +0x17yy for shim +0x18yy for IL Verifier +0x19yy for .NET Framework +0x1Ayy for .NET Framework +0x1Byy for MetaData Validator +0x30yy for VSA errors + +CLR HRESULTs are defined in corerror.h. If you make any modifications to +the range allocations described above, please make sure the corerror.h file +gets updated. +*/ + +namespace System +{ + using System; + + internal static class HResults + { + + internal const int Configuration = unchecked((int)0x80131902); + + // Xml + internal const int Xml = unchecked((int)0x80131940); + internal const int XmlSchema = unchecked((int)0x80131941); + internal const int XmlXslt = unchecked((int)0x80131942); + internal const int XmlXPath = unchecked((int)0x80131943); + + // DataSet + internal const int Data = unchecked((int)0x80131920); + internal const int DataDeletedRowInaccessible = unchecked((int)0x80131921); + internal const int DataDuplicateName = unchecked((int)0x80131922); + internal const int DataInRowChangingEvent = unchecked((int)0x80131923); + internal const int DataInvalidConstraint = unchecked((int)0x80131924); + internal const int DataMissingPrimaryKey = unchecked((int)0x80131925); + internal const int DataNoNullAllowed = unchecked((int)0x80131926); + internal const int DataReadOnly = unchecked((int)0x80131927); + internal const int DataRowNotInTable = unchecked((int)0x80131928); + internal const int DataVersionNotFound = unchecked((int)0x80131929); + internal const int DataConstraint = unchecked((int)0x8013192A); + internal const int StrongTyping = unchecked((int)0x8013192B); + + // Managed Providers + internal const int SqlType = unchecked((int)0x80131930); + internal const int SqlNullValue = unchecked((int)0x80131931); + internal const int SqlTruncate = unchecked((int)0x80131932); + internal const int AdapterMapping = unchecked((int)0x80131933); + internal const int DataAdapter = unchecked((int)0x80131934); + internal const int DBConcurrency = unchecked((int)0x80131935); + internal const int OperationAborted = unchecked((int)0x80131936); + internal const int InvalidUdt = unchecked((int)0x80131937); + internal const int Metadata = unchecked((int)0x80131939); + internal const int InvalidQuery = unchecked((int)0x8013193A); + internal const int CommandCompilation = unchecked((int)0x8013193B); + internal const int CommandExecution = unchecked((int)0x8013193C); + + + internal const int SqlException = unchecked((int)0x80131904); // System.Data.SqlClient.SqlClientException + internal const int OdbcException = unchecked((int)0x80131937); // System.Data.Odbc.OdbcException + internal const int OracleException = unchecked((int)0x80131938); // System.Data.OracleClient.OracleException + internal const int ConnectionPlanException = unchecked((int)0x8013193d); // System.Data.SqlClient.ConnectionPlanException + + // Configuration encryption + internal const int NteBadKeySet = unchecked((int)0x80090016); + + // Win32 + internal const int Win32AccessDenied = unchecked((int)0x80070005); + internal const int Win32InvalidHandle = unchecked((int)0x80070006); + + +#if !FEATURE_PAL + internal const int License = unchecked((int)0x80131901); + internal const int InternalBufferOverflow = unchecked((int)0x80131905); + internal const int ServiceControllerTimeout = unchecked((int)0x80131906); + internal const int Install = unchecked((int)0x80131907); + + // Win32 + internal const int EFail = unchecked((int)0x80004005); +#endif + } +} + +