Code Analysis Code Analysis
Code Analysis Code Analysis
DocFX + Singulink = ♥

Search Results for

    SCA1042: Line of a Symbol List File

    Fix the line of the symbol list file.

    A line of a symbol list file, such as NonCopyableSymbols.txt, cannot be parsed, has no effect, or says that a member which clones makes no copy.

    Example

    M:ThirdParty.Bag`1.Take;noncopyable             # SCA1042: the marker 'noncopyable' is for a type
    T:ThirdParty.Handel;noncopyable                 # SCA1042: names no type of the compilation
    M:System.Globalization.CultureInfo.Clone        # SCA1042: a 'clones' line says that Clone clones its object
    M:ThirdParty.Bag`1.Take;new                     # OK
    T:ThirdParty.Handle;noncopyable                 # OK
    

    How to Fix

    Fix the ID or the marker, or take the line out of the file of a project that does not reference what it names.

    Details

    Lines That Cannot Be Parsed

    A line of a NonCopyableSymbols.txt file cannot be parsed, and is ignored, if it has:

    • an ID that cannot be a documentation comment ID;
    • a for= that names a type parameter which the member does not have, or a name that could refer to more than one type parameter;
    • a marker on something that it does not fit: see Lines That Are Ignored or Get a Warning;
    • clones=complete or clones=none on a method, a property or an event, a value of clones other than complete or none, or complete or none written as a marker of its own;
    • a marker other than trusted on an assembly, trusted on anything but an assembly, or an assembly given by a display name with a version or by a file name.

    Lines That Have No Effect

    Line Warning when
    noncopyable It names no type of the compilation, which would leave the type copyable
    copyable It names no type, names a struct that the project declares itself, or a struct that nothing makes non-copyable by itself
    trusted The assembly is not referenced, is the project's own or was built with the analyzer. Or the line answers nothing: the assembly gets no SCA1025, and no class of the project that derives from one of its classes holds a non-copyable value in a field
    clones=none It names a class of the project, of the framework or of a library that was built with the analyzers, or a class that is static or sealed. Or a clones line names the class or a class above it
    clones It names no type, method, property or event of the compilation, or a class that is static, or sealed and not generic, from which no class can derive and to which no type can be bound. A clones=complete line for a sealed class below a class that clones itself has an effect: it covers the members of that class
    A member line of any marker that names an accessor (get_, set_, add_ or remove_) Always. The analyzer looks up every use of an accessor under its property or event, so the line has no effect: write the P: or E: line instead
    A member line for a member that the built-in framework symbol list names with for= It names a type parameter that the line of the framework symbol list leaves out, or it has no for=. A line of a file can claim less of a member than the framework symbol list, not more, so the analyzer leaves the line out. A line of a file that came in a package gets this warning only in the library's own build

    Lines That Say a Member Which Clones Makes No Copy

    A member line with no marker, or with new, borrows, drains or owned, says that the member makes no copy. Where a clones line, of the built-in framework symbol list or of a symbol list file, says that the member clones its object, the line gets this warning and is left out, and every use of the member keeps its warning. Remove the line.

    See Also

    These articles explain the rule behind this warning:

    • Symbol List Format - every marker, and the rules for entries.
    • Symbol List - where symbol list files go.
    © Singulink. All rights reserved.