Git Product home page Git Product logo

externalannotations's Introduction

official JetBrains project

JetBrains ReSharper External Annotations

The default set of external annotations that ships with ReSharper and Rider.

externalannotations's People

Contributors

alan-pinkert-llamasoft avatar bdukes avatar citizenmatt avatar controlflow avatar derigel23 avatar drauch avatar drewnoakes avatar estrizhok avatar fornever avatar githubpang avatar johnradke avatar knah avatar konstantin-kretov avatar leotsarev avatar lsedlacek avatar magol avatar markrendle avatar mr146 avatar mreditor avatar nikolayglushakov avatar nn--- avatar saltukkos avatar sergeyqx avatar sirduke avatar sqrtz avatar tessenr avatar tom-englert avatar ulex avatar ulrichb avatar x-cubed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

externalannotations's Issues

Nullability contract of IValidatableObject.Validate()

Proposal: Add [NotNull] to the Validate() result and validationContext parameter.

(This issue duplicates RSRP-427424.)

Reasoning for a [NotNull] validationContext parameter

Therefore it makes no sense to implement an argument null check in a Validate() interface implementation for objects which will be validated by the BCL and the new annotation would guide us to avoid this.

Reasoning for a [NotNull] result

Mark NugetPackage as DevelopmentDependency

If you add <developmentDependency>true</developmentDependency>
in your Metadata Block in your Nuspec File, it will install itself as a Development Dependency.
You can see it for Example here Nuspec

Duplicate back ticks in member names.

Many generic member names contain duplicated back ticks, e.g.
<member name="M:System.Tuple.Create``1(``0)">
instead of
<member name="M:System.Tuple.Create`1(`0)">
(6899 member names with single ticks, 4533 member names with duplicate ticks)

This is not according to the specification, and makes parsing hard and error prone.

Message parameters in System.Diagnostics.Trace/Debug/TraceListener

At the moment the message parameters of Trace, Debug, and TraceListener methods are annotated with [NotNull]. Example: Trace.Write(string).

This is incorrect because there are no not-null preconditions (or guarding checks) in the concerned BCL classes. Also the BCL TraceListener implementations can cope with message null arguments (e.g. DefaultTraceListener here, here and here, or TextWriterTraceListener here and here).

=> Message null arguments are OK, and custom TraceListener implementations should be aware of that. But: At the moment R# warns about null arguments, and worse, suggests to remove null-handling in TraceListener implementations (see the following screenshot).

In the screenshot you can also see that (except for the "format string overloads") the null arguments do not raise any error.

Sample

Same with Debug class:
Sample

System.Exception.InnerException can be null

I'm using the experimental implicit not-null setting in R# 2016.1 and every time I test Exception.InnerException for null, R# says it's always false which is definitely not the case.

I looked through the files here and couldn't find any reference to InnerException.

Also, I read the documents linked to from the README, but I couldn't find any information on how to contribute to this repo. The structure here is more involved than what's mentioned in the docs.

NotNull contract for Assembly.Location should be CanBeNull

<member name="P:System.Reflection.Assembly.Location">

System.Reflection.Assembly.Location can be null, when the assembly is loaded from memory (for example, when dynamically compiling an assembly in memory and/or loading the assembly using Assembly.Load(byte[]).

capture

I encountered numerous bugs in our systems (even in some official MS packages) where 'Location' is not checked for null/empty.

Resharper is definitely not helping here. It even suggests to remove the null check.

I think the annotation should be replaced by 'CanBeNull'.

Ninject should be annotated

Ninject is a commonly used dependency injection container. Having annotations for this library would be very beneficial.

No annotations for System.Net.Http

The System.Net.Http assembly should be annotated. Specifically, the following methods should be marked as NotNull:

  • CopyToAsync
  • CreateContentReadStreamAsync
  • LoadIntoBufferAsync
  • ReadAsByteArrayAsync
  • ReadAsStreamAsync
  • ReadAsStringAsync
  • SerializeToStreamAsync

~2000 missing or wrong annotations!

After getting a lot of false positives with R# I have compared the ExternalAnnotations with Code Contracts and found a lot of differences.

While 3933 methods/props have identical nullability contracts, 1091 methods/props are missing at all, and 679 methods/props are different (mostly parts missing on R# side).

I have attached the results of my analysis, where RS* are the normalized ExternalAnnotations and CC* are the corresponding contracts exported from the Code Contracts project. All files are in ExternalAnnotations xml format.

OK are the ones where both have the same outcome.
CC and RS contain the the differences (compare both folders with e.g. BeyondCompare)
CCOnly are the ones defined only in Code Contracts and missing in R#

For the differences most times CC is more exact, but not always, so these would need an extra review.

Contracts.zip

Missing annotations for XAttribute (and maybe for some other items)

In this code block, ReSharper doesn't warn that attrib.Value is a possible NullReferenceException

void Foo()
{
var xe = XElement.Parse("");
var attrib = xe.Attribute("a");
var value = attrib.Value;
}

The inspection is there if I set the .NET Framework 3.5. for the project. If I choose anything higher than that, it doesn't work.

Ability to generate MyLibrary.ExternalAnnotations.xml during build or otherwise

Given the attributes in the JetBrains.Annotations NuGet package are [Conditional("JETBRAINS_ANNOTATIONS")], they're not present in compiled library code (I could set the condition symbol, but I'm happy leaving them out of the DLL's metadata).

I'd like users of my library to benefit from these annotations, but I don't want to maintain the XML by hand.

Is it possible to have them generated automatically, perhaps as part of the build process?

If so, would including them in nupkg files be enough to have them picked up by users of my NuGet packages?

SqlParameterCollection.Add return value should be marked as NotNull

When adding a Parameter to a SqlCommand, ReSharper reports that the return value can be null. Currently, ReSharper would report that the two Add methods could be null. Setting the Value property would result in a "red squiggle" to appear from the beginning of the line until the dot just before Value.

private void Example()
{
    const string SqlText = "UPDATE A SET B = @B WHERE C = @C";

    using (var conn = new SqlConnection(this.ConnectionString))
    {
        conn.Open();
        using (var command = new SqlCommand(SqlText, conn))
        {
            command.CommandType = CommandType.Text;
            command.Parameters.Add("@B", SqlDbType.VarChar, 255).Value = "B";
            command.Parameters.Add("@C", SqlDbType.Int).Value = 1;
            command.ExecuteNonQuery();
        }
    }
}

Member names should be consistent

Names for methods with no parameters should either all end with () or all without ()

e.g. M:Microsoft.CSharp.Error.NotImplemented
should be M:Microsoft.CSharp.Error.NotImplemented()

There are 1530 methods with () and 15105 without ()

Package install fails on .NET Core project in VS2017 RC

Repro steps:

  • Install VS 2017 RC with Web/Cloud workload
  • Create a new ASP.NET Core application (MVC)
  • From the package manager console: install-package jetbrains.externalannotations

Actual:

install-package : Package JetBrains.ExternalAnnotations 10.2.3 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package JetBrains.ExternalAnnotations 10.2.3 supports: net (.NETFramework,Version=v0.0)
At line:1 char:1
+ install-package jetbrains.externalannotations
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
 
install-package : One or more packages are incompatible with .NETCoreApp,Version=v1.0.
At line:1 char:1
+ install-package jetbrains.externalannotations
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
 
install-package : Package restore failed. Rolling back package changes for 'CoreWebApplication1'.
At line:1 char:1
+ install-package jetbrains.externalannotations
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
 

Expected: successful installation.

Can't find it in Extension Manager?

I am using Visual Studio 2017 and ReSharper 2016.3.2
For some reason I can't find this package https://resharper-plugins.jetbrains.com/packages/ReSharper.ExternalAnnotations/ in my Extension Manager. When I search for External Annotations I get only this: Community ReSharper External Annotations
I've installed the nuget package: https://www.nuget.org/packages/JetBrains.ExternalAnnotations/ but I'm not sure if it's the same thing? Can someone clarify this for me?
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.