Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement RS0042 (Do not copy value) #3420

Merged
merged 17 commits into from
Apr 19, 2020
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ private bool IsCountMethodInvocation(IOperation operation, [NotNullWhen(returnVa
{
methodName = null;

operation = operation.WalkDownParenthesis();
operation = operation.WalkDownParentheses();

operation = operation.WalkDownConversion();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Rule ID | Category | Severity | Notes
--------|----------|----------|-------
RS0040 | RoslynDiagnosticsReliability | Warning | DefaultableTypeShouldHaveDefaultableFieldsAnalyzer
RS0042 | RoslynDiagnosticsReliability | Warning | DoNotCopyValue
RS0043 | RoslynDiagnosticsMaintainability | Warning | DoNotCallGetTestAccessor
RS0044 | RoslynDiagnosticsMaintainability | Hidden | CreateTestAccessor
RS0045 | RoslynDiagnosticsMaintainability | Hidden | ExposeMemberForTesting
Expand Down
1,443 changes: 1,443 additions & 0 deletions src/Roslyn.Diagnostics.Analyzers/Core/DoNotCopyValue.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ internal static class RoslynDiagnosticIds
public const string RelaxTestNamingSuppressionRuleId = "RS0039";
public const string DefaultableTypeShouldHaveDefaultableFieldsRuleId = "RS0040";
public const string ObliviousPublicApiRuleId = "RS0041";
public const string DoNotCopyValueRuleId = "RS0042";
public const string DoNotCallGetTestAccessorRuleId = "RS0043";
public const string CreateTestAccessorRuleId = "RS0044";
public const string ExposeMemberForTestingRuleId = "RS0045";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,39 @@
<data name="DefaultableTypeShouldHaveDefaultableFieldsTitle" xml:space="preserve">
<value>Defaultable types should have defaultable fields</value>
</data>
<data name="DoNotCopyValueDescription" xml:space="preserve">
<value>Do not copy value</value>
</data>
<data name="DoNotCopyValueMessage" xml:space="preserve">
<value>Do not copy value</value>
</data>
<data name="DoNotCopyValueTitle" xml:space="preserve">
<value>Do not copy value</value>
</data>
<data name="DoNotCopyValueNoBoxingDescription" xml:space="preserve">
<value>Do not box non-copyable value types.</value>
</data>
<data name="DoNotCopyValueNoBoxingMessage" xml:space="preserve">
<value>Do not box non-copyable type '{0}'</value>
</data>
<data name="DoNotCopyValueUnsupportedUseDescription" xml:space="preserve">
<value>Unsupported use of non-copyable type</value>
</data>
<data name="DoNotCopyValueUnsupportedUseMessage" xml:space="preserve">
<value>Unsupported use of non-copyable type '{0}' in '{1}' operation</value>
</data>
<data name="DoNotCopyValueNoUnboxingDescription" xml:space="preserve">
<value>Do not unbox non-copyable value types.</value>
</data>
<data name="DoNotCopyValueNoUnboxingMessage" xml:space="preserve">
<value>Do not unbox non-copyable type '{0}'</value>
</data>
<data name="DoNotCopyValueAvoidNullableWrapperDescription" xml:space="preserve">
<value>Avoid nullable wrapper</value>
</data>
<data name="DoNotCopyValueAvoidNullableWrapperMessage" xml:space="preserve">
<value>Do not wrap non-copyable type '{0}' in '{1}' operation</value>
</data>
<data name="DoNotCallGetTestAccessorDescription" xml:space="preserve">
<value>GetTestAccessor() is a helper method reserved for testing. Production code must not call this member.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,61 @@
<target state="new">Do not call GetTestAccessor()</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueAvoidNullableWrapperDescription">
<source>Avoid nullable wrapper</source>
<target state="new">Avoid nullable wrapper</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueAvoidNullableWrapperMessage">
<source>Do not wrap non-copyable type '{0}' in '{1}' operation</source>
<target state="new">Do not wrap non-copyable type '{0}' in '{1}' operation</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueDescription">
<source>Do not copy value</source>
<target state="new">Do not copy value</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueMessage">
<source>Do not copy value</source>
<target state="new">Do not copy value</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueNoBoxingDescription">
<source>Do not box non-copyable value types.</source>
<target state="new">Do not box non-copyable value types.</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueNoBoxingMessage">
<source>Do not box non-copyable type '{0}'</source>
<target state="new">Do not box non-copyable type '{0}'</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueNoUnboxingDescription">
<source>Do not unbox non-copyable value types.</source>
<target state="new">Do not unbox non-copyable value types.</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueNoUnboxingMessage">
<source>Do not unbox non-copyable type '{0}'</source>
<target state="new">Do not unbox non-copyable type '{0}'</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueTitle">
<source>Do not copy value</source>
<target state="new">Do not copy value</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueUnsupportedUseDescription">
<source>Unsupported use of non-copyable type</source>
<target state="new">Unsupported use of non-copyable type</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueUnsupportedUseMessage">
<source>Unsupported use of non-copyable type '{0}' in '{1}' operation</source>
<target state="new">Unsupported use of non-copyable type '{0}' in '{1}' operation</target>
<note />
</trans-unit>
<trans-unit id="ExportedPartsShouldHaveImportingConstructorCodeFix_ImplicitConstructor">
<source>Explicitly define the importing constructor</source>
<target state="translated">Explicitně definujte importující konstruktor.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,61 @@
<target state="new">Do not call GetTestAccessor()</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueAvoidNullableWrapperDescription">
<source>Avoid nullable wrapper</source>
<target state="new">Avoid nullable wrapper</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueAvoidNullableWrapperMessage">
<source>Do not wrap non-copyable type '{0}' in '{1}' operation</source>
<target state="new">Do not wrap non-copyable type '{0}' in '{1}' operation</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueDescription">
<source>Do not copy value</source>
<target state="new">Do not copy value</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueMessage">
<source>Do not copy value</source>
<target state="new">Do not copy value</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueNoBoxingDescription">
<source>Do not box non-copyable value types.</source>
<target state="new">Do not box non-copyable value types.</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueNoBoxingMessage">
<source>Do not box non-copyable type '{0}'</source>
<target state="new">Do not box non-copyable type '{0}'</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueNoUnboxingDescription">
<source>Do not unbox non-copyable value types.</source>
<target state="new">Do not unbox non-copyable value types.</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueNoUnboxingMessage">
<source>Do not unbox non-copyable type '{0}'</source>
<target state="new">Do not unbox non-copyable type '{0}'</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueTitle">
<source>Do not copy value</source>
<target state="new">Do not copy value</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueUnsupportedUseDescription">
<source>Unsupported use of non-copyable type</source>
<target state="new">Unsupported use of non-copyable type</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueUnsupportedUseMessage">
<source>Unsupported use of non-copyable type '{0}' in '{1}' operation</source>
<target state="new">Unsupported use of non-copyable type '{0}' in '{1}' operation</target>
<note />
</trans-unit>
<trans-unit id="ExportedPartsShouldHaveImportingConstructorCodeFix_ImplicitConstructor">
<source>Explicitly define the importing constructor</source>
<target state="translated">Importierenden Konstruktor explizit definieren</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,61 @@
<target state="new">Do not call GetTestAccessor()</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueAvoidNullableWrapperDescription">
<source>Avoid nullable wrapper</source>
<target state="new">Avoid nullable wrapper</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueAvoidNullableWrapperMessage">
<source>Do not wrap non-copyable type '{0}' in '{1}' operation</source>
<target state="new">Do not wrap non-copyable type '{0}' in '{1}' operation</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueDescription">
<source>Do not copy value</source>
<target state="new">Do not copy value</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueMessage">
<source>Do not copy value</source>
<target state="new">Do not copy value</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueNoBoxingDescription">
<source>Do not box non-copyable value types.</source>
<target state="new">Do not box non-copyable value types.</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueNoBoxingMessage">
<source>Do not box non-copyable type '{0}'</source>
<target state="new">Do not box non-copyable type '{0}'</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueNoUnboxingDescription">
<source>Do not unbox non-copyable value types.</source>
<target state="new">Do not unbox non-copyable value types.</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueNoUnboxingMessage">
<source>Do not unbox non-copyable type '{0}'</source>
<target state="new">Do not unbox non-copyable type '{0}'</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueTitle">
<source>Do not copy value</source>
<target state="new">Do not copy value</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueUnsupportedUseDescription">
<source>Unsupported use of non-copyable type</source>
<target state="new">Unsupported use of non-copyable type</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueUnsupportedUseMessage">
<source>Unsupported use of non-copyable type '{0}' in '{1}' operation</source>
<target state="new">Unsupported use of non-copyable type '{0}' in '{1}' operation</target>
<note />
</trans-unit>
<trans-unit id="ExportedPartsShouldHaveImportingConstructorCodeFix_ImplicitConstructor">
<source>Explicitly define the importing constructor</source>
<target state="translated">Definir explícitamente el constructor de importación</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,61 @@
<target state="new">Do not call GetTestAccessor()</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueAvoidNullableWrapperDescription">
<source>Avoid nullable wrapper</source>
<target state="new">Avoid nullable wrapper</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueAvoidNullableWrapperMessage">
<source>Do not wrap non-copyable type '{0}' in '{1}' operation</source>
<target state="new">Do not wrap non-copyable type '{0}' in '{1}' operation</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueDescription">
<source>Do not copy value</source>
<target state="new">Do not copy value</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueMessage">
<source>Do not copy value</source>
<target state="new">Do not copy value</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueNoBoxingDescription">
<source>Do not box non-copyable value types.</source>
<target state="new">Do not box non-copyable value types.</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueNoBoxingMessage">
<source>Do not box non-copyable type '{0}'</source>
<target state="new">Do not box non-copyable type '{0}'</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueNoUnboxingDescription">
<source>Do not unbox non-copyable value types.</source>
<target state="new">Do not unbox non-copyable value types.</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueNoUnboxingMessage">
<source>Do not unbox non-copyable type '{0}'</source>
<target state="new">Do not unbox non-copyable type '{0}'</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueTitle">
<source>Do not copy value</source>
<target state="new">Do not copy value</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueUnsupportedUseDescription">
<source>Unsupported use of non-copyable type</source>
<target state="new">Unsupported use of non-copyable type</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueUnsupportedUseMessage">
<source>Unsupported use of non-copyable type '{0}' in '{1}' operation</source>
<target state="new">Unsupported use of non-copyable type '{0}' in '{1}' operation</target>
<note />
</trans-unit>
<trans-unit id="ExportedPartsShouldHaveImportingConstructorCodeFix_ImplicitConstructor">
<source>Explicitly define the importing constructor</source>
<target state="translated">Définir explicitement le constructeur d'importation</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,61 @@
<target state="new">Do not call GetTestAccessor()</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueAvoidNullableWrapperDescription">
<source>Avoid nullable wrapper</source>
<target state="new">Avoid nullable wrapper</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueAvoidNullableWrapperMessage">
<source>Do not wrap non-copyable type '{0}' in '{1}' operation</source>
<target state="new">Do not wrap non-copyable type '{0}' in '{1}' operation</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueDescription">
<source>Do not copy value</source>
<target state="new">Do not copy value</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueMessage">
<source>Do not copy value</source>
<target state="new">Do not copy value</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueNoBoxingDescription">
<source>Do not box non-copyable value types.</source>
<target state="new">Do not box non-copyable value types.</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueNoBoxingMessage">
<source>Do not box non-copyable type '{0}'</source>
<target state="new">Do not box non-copyable type '{0}'</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueNoUnboxingDescription">
<source>Do not unbox non-copyable value types.</source>
<target state="new">Do not unbox non-copyable value types.</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueNoUnboxingMessage">
<source>Do not unbox non-copyable type '{0}'</source>
<target state="new">Do not unbox non-copyable type '{0}'</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueTitle">
<source>Do not copy value</source>
<target state="new">Do not copy value</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueUnsupportedUseDescription">
<source>Unsupported use of non-copyable type</source>
<target state="new">Unsupported use of non-copyable type</target>
<note />
</trans-unit>
<trans-unit id="DoNotCopyValueUnsupportedUseMessage">
<source>Unsupported use of non-copyable type '{0}' in '{1}' operation</source>
<target state="new">Unsupported use of non-copyable type '{0}' in '{1}' operation</target>
<note />
</trans-unit>
<trans-unit id="ExportedPartsShouldHaveImportingConstructorCodeFix_ImplicitConstructor">
<source>Explicitly define the importing constructor</source>
<target state="translated">Definire esplicitamente il costruttore di importazione</target>
Expand Down
Loading