SmartAssembly - 5.0

SmartAssembly
DRAFT:   Help content is still under construction.

Learning SmartAssembly - 5.0

Using custom attributes

Defining attributes

To define the attributes, do one of the following:

  • Add a reference to the SmartAssembly.Attributes.dll (located in the smartassembly\attributes folder) in your project.
  • Add the source code file to your project (SmartAssembly.Attributes.cs for a C# project, or SmartAssembly.Attributes.vb for a VB.NET project). Both files are located in the Smartassembly\attributes folder. If you choose this option, you can change the namespace to match your own, simplifying the use of these attributes.

Using the attributes

DoNotObfuscateAttribute

Excludes the member from the obfuscation.

Can be added to assembly, class, delegate, enum, field, interface, method, module, and struct.

DoNotObfuscateTypeAttribute

Excludes the type definition, as well as all the type's members from the obfuscation.

Can be added to any type (class, enum, interface, and struct).

DoNotPruneAttribute

Excludes the type definition, as well as all type's members from the pruning.

Can be added to any type (class, enum, interface, and struct).

 

DoNotPruneTypeAttribute

Excludes the type definition as well as all type's members from the pruning.

Can be added to any type (class, enum, interface, and struct).

DoNotSealTypeAttribute

Does not seal the type, even if you set the option to automatically seal all possible classes.

Can be added to any type (class, enum, interface, and struct).

ReportExceptionAttribute

Reports any unhandled exception, which occurs in this method.

Can be added to any method.

ObfuscateControlFlowAttribute

Adds stronger control flow obfuscation to the method, or to the methods of the type.

Can be added to any class, method, and struct.

C# code sample

[DoNotSealType()]

public class MyClass

{

[DoNotPrune()]

[DoNotObfuscate()]

public void CalledOnlyByReflection()

{

}

[DoNotPrune()]

public string MyPropertyCalledByReflection

{

get

{

return "hello world";

}

}

public void DoSomething([DoNotPrune()] string myString)

{

}

[ReportException()]

[ObfuscateControlFlow()]

public void DoSomethingDangerous()

{

}

public MyClass()

{

}

[DoNotPrune()]

public MyClass(string[] args)

{

//Called only by Reflection

}

}

[DoNotPruneType()]

[DoNotObfuscateType()]

public class OtherClass

{

}

VB.NET code sample

<DoNotSealType()> _

Public Class Class1

<DoNotPrune(), DoNotObfuscate()> _

Public Sub CalledOnlyByReflection()

End Sub

<DoNotPrune()> _

Public ReadOnly Property

MyPropertyCalledByReflection()

Get

Return "hello world"

End Get

End Property

Public Sub DoSomething(<DoNotPrune()> ByVal MyString As String)

End Sub

<ReportException()> _

<ObfuscateControlFlow()> _

Public Sub DoSomethingDangerous()

End Sub

Public Sub New()

End Sub

<DoNotPrune()> _

Public Sub New(ByVal args As String())

REM Called only by Reflection

End Sub

End Class

<DoNotPruneType(), DoNotObfuscateType()> _

Public Class OtherClaEss

End Class

DRAFT:   Help content is still under construction.

Was this article helpful?

Search support
Forums
Visit the SmartAssembly forum.

SmartAssembly

all products