You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Rule S4226 (Extensions should be in separate namespaces) notes in the description: "It makes little sense to create an extension method when it is possible to just add that method to the class itself."
If the base class is a generated class (e.g. using xsd.exe or xsd2code) it is not "possible to just add that method to the class itself".
So, I ask to add exception for generated classes, e.g. annotated with System.CodeDom.Compiler.GeneratedCodeAttribute.
Repro steps
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd","4.8.3928.0")][System.SerializableAttribute()][System.Diagnostics.DebuggerStepThroughAttribute()][System.ComponentModel.DesignerCategoryAttribute("code")]publicabstractpartialclassReplyWithErrorListBase{privateReplyErrorListError[]errorListField;/// <remarks/>[System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)][System.Xml.Serialization.XmlArrayItemAttribute("Error",Form=System.Xml.Schema.XmlSchemaForm.Unqualified,IsNullable=false)]publicReplyErrorListError[]ErrorList{get{returnthis.errorListField;}set{this.errorListField=value;}}}internalstaticclassReplyErrorExtensions{publicstaticvoidSetSyncLaterError(thisReplyWithErrorListBasereply)// SHOULD NOT RAISE!{reply.ErrorList=new[]{newReplyErrorListError{Code=1,Text="foo"}};}}
Description
The Rule S4226 (Extensions should be in separate namespaces) notes in the description: "It makes little sense to create an extension method when it is possible to just add that method to the class itself."
If the base class is a generated class (e.g. using xsd.exe or xsd2code) it is not "possible to just add that method to the class itself".
So, I ask to add exception for generated classes, e.g. annotated with
System.CodeDom.Compiler.GeneratedCodeAttribute
.Repro steps
Expected behavior
S4226 should not raise.
Actual behavior
Warning: "Either move this extension to another namespace or move the method inside the class itself."
Known workarounds
N/A
Related information
The text was updated successfully, but these errors were encountered: