wintellect / wintellect.analyzers Goto Github PK
View Code? Open in Web Editor NEW.NET Compiler Platform ("Roslyn") diagnostic analyzers and code fixes written by Wintellect
License: Other
.NET Compiler Platform ("Roslyn") diagnostic analyzers and code fixes written by Wintellect
License: Other
AvoidPredefinedTypes
The predefined types, such as int, should not be used. When defining a type the built in types can be different sizes on different versions of .NET (e.g., desktop and Internet of Things) so you want to be as explicit about types as possible. "
This is incorrect. See section 4.1.4 of the C# specification.
C# provides a set of predefined struct types called the simple types. The simple types are identified through reserved words, but these reserved words are simply aliases for predefined struct types in the System namespace, as described in the table below.
Reserved word | Aliased type |
---|---|
sbyte | System.SByte |
byte | System.Byte |
short | System.Int16 |
ushort | System.UInt16 |
int | System.Int32 |
uint | System.UInt32 |
long | System.Int64 |
ulong | System.UInt64 |
char | System.Char |
float | System.Single |
double | System.Double |
bool | System.Boolean |
decimal | System.Decimal |
Could you please update the README with a quick section explaining how to add and configure the analyzers in a CI environment?
Hi,
I have created a fresh Win10 VM with VS2015 (from Azure catalog) and then created an empty C# console-project, added the Wintellect.Analyzers with nuget and built it.
The following warning appeared in the "Error List"-Window:
Warning MissingAnalyzerReference Analyzer assembly 'c:\users\fk\documents\visual studio 2015\Projects\ConsoleApplication1\packages\Wintellect.Analyzers.1.0.0.0\analyzers\dotnet\cs\Wintellect.Analyzers.Test.dll' depends on 'Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' but it was not found. Analyzers may not run correctly.
Why would I want to pick the defined types in System namespace when 99.9% of the code I see everywhere, on Github, at work...at my previous company all use the built in C# aliases.
Don't you find that using the built in System types can become a little confusing when comparing to important objects/structs in the Framework?
Using the C# pre-defined keyword seems much clearer to a developer that the person does indeed mean to use System.String when they use 'string'.
What if I made a custom Object in my own namespace named Int32 or String like
namespace PatrickMagee
{
public class String
{
}
}
Then used the return type String (from my namespace).
Where is this Analyzer useful? π±
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.