Home

Awesome

Nuget Downloads Visual Studio Marketplace Downloads

Demonstration of an analyzer which removes unnecessary IEnumerable materializations

Quickstart

Install it through the command line:

Install-Package SharpSource

or add a reference yourself:

<ItemGroup>
    <PackageReference Include="SharpSource" Version="1.25.2" PrivateAssets="All" />
</ItemGroup>

If you would like to install it as an extension instead, download it from the marketplace.


This repo houses a collection of analyzers that aim to make some language features and framework types easier to work with. It does this by highlighting when you might be using something incorrectly in a way that would result in suboptimal performance, runtime exceptions or general unintended behaviour.

In other words, this repo only contains analyzers for patterns that have a concrete potential to turn into a defect ticket. It is not intended to help with general housekeeping tasks like formatting your code or providing productivity helpers.

Interested in contributing? Take a look at the guidelines!


Detailed explanations of each analyzer can be found in the documentation: https://github.com/Vannevelj/SharpSource/tree/master/docs

CodeName
SS001AsyncMethodWithVoidReturnType
SS002DateTimeNow
SS003DivideIntegerByInteger
SS004ElementaryMethodsOfTypeInCollectionNotOverridden
SS005EqualsAndGetHashcodeNotImplementedTogether
SS006ThrowNull
SS007FlagsEnumValuesAreNotPowersOfTwo
SS008GetHashCodeRefersToMutableMember
SS009LoopedRandomInstantiation
SS010NewGuid
SS011OnPropertyChangedWithoutNameofOperator
SS012RecursiveOperatorOverload
SS013RethrowExceptionWithoutLosingStacktrace
SS014StringDotFormatWithDifferentAmountOfArguments
SS015StringPlaceholdersInWrongOrder
SS017StructWithoutElementaryMethodsOverridden
SS018SwitchDoesNotHandleAllEnumOptions
SS019SwitchIsMissingDefaultLabel
SS020TestMethodWithoutPublicModifier
SS021TestMethodWithoutTestAttribute
SS022ExceptionThrownFromImplicitOperator
SS023ExceptionThrownFromPropertyGetter
SS024ExceptionThrownFromStaticConstructor
SS025ExceptionThrownFromFinallyBlock
SS026ExceptionThrownFromEqualityOperator
SS027ExceptionThrownFromDispose
SS028ExceptionThrownFromFinalizer
SS029ExceptionThrownFromGetHashCode
SS030ExceptionThrownFromEquals
SS032ThreadSleepInAsyncMethod
SS033AsyncOverloadsAvailable
SS034AccessingTaskResultWithoutAwait
SS035SynchronousTaskWait
SS036ExplicitEnumValues
SS037HttpClientInstantiatedDirectly
SS038HttpContextStoredInField
SS039EnumWithoutDefaultValue
SS040UnusedResultOnImmutableObject
SS041UnnecessaryEnumerableMaterialization
SS042InstanceFieldWithThreadStatic
SS043MultipleFromBodyParameters
SS044AttributeMustSpecifyAttributeUsage
SS045StaticInitializerAccessedBeforeInitialization
SS046UnboundedStackalloc
SS047LinqTraversalBeforeFilter
SS048LockingOnDiscouragedObject
SS049ComparingStringsWithoutStringComparison
SS050ParameterAssignedInConstructor
SS051LockingOnMutableReference
SS052ThreadStaticWithInitializer
SS053PointlessCollectionToString
SS054NewtonsoftMixedWithSystemTextJson
SS055MultipleOrderByCalls
SS056FormReadSynchronously
SS057CollectionManipulatedDuringTraversal
SS058StringConcatenatedInLoop
SS059DisposeAsyncDisposable
SS060ConcurrentDictionaryEmptyCheck

Configuration

Is a particular rule not to your liking? There are many ways to adjust their severity and even disable them altogether. For an overview of some of the options, check out this document.