Skip to content

Commit 0de57bd

Browse files
committed
DOCSP-33158: unsupported builders expressions (#79)
* DOCSP-33158: unsupported builders expressions * remove file * RM PR fixes 1 * RM small fix (cherry picked from commit 2093ff1)
1 parent 8c0d828 commit 0de57bd

File tree

6 files changed

+54
-32
lines changed

6 files changed

+54
-32
lines changed

.github/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

source/code-type/builders.txt

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,39 @@ with or without an information message displayed:
132132
.. figure:: /includes/images/fluent-api-popup.png
133133
:alt: Screenshot of Fluent API with an information message displayed in Visual Studio.
134134

135-
.. include:: /includes/error-list-window.rst
135+
.. include:: /includes/error-list-window.rst
136+
137+
.. _mongodb-analyzer-unsupported-builders:
138+
139+
Unsupported Builder Expressions
140+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
141+
142+
If your builder expression is not supported, the {+product-short+} outputs a
143+
``MABuilders2001`` warning.
144+
145+
The following code snippet contains a builder expression that accesses the
146+
unsupported ``Length`` property:
147+
148+
.. code-block:: csharp
149+
150+
var filter = Builders<Movie>.Filter.Gt(m => m.Reviews.Length, 2);
151+
152+
The {+product-short+} shows an annotation on the unsupported expression
153+
and generates the following warning message:
154+
155+
.. code-block:: text
156+
:copyable: false
157+
158+
Expression not supported: ArrayLength(m.Reviews).
159+
160+
The following screenshot shows the annotated code and the warning
161+
displayed when you hover over the annotation:
162+
163+
.. figure:: /includes/images/builders-unsupported-popup.jpg
164+
:alt: Screenshot of warning displayed in Visual Studio from unsupported builder expression.
165+
166+
.. include:: /includes/error-list-window.rst
167+
168+
To view more examples of unsupported builder expressions, see the
169+
`{+product+} Github repository
170+
<{+product-source-repo+}/blob/main/tests/MongoDB.Analyzer.Tests.Common.TestCases/Builders/NotSupportedBuildersExpressions.cs>`__.

source/code-type/linq.txt

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -146,42 +146,28 @@ Unsupported LINQ Expressions
146146
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
147147

148148
If your LINQ expression is not supported, the {+product-short+} outputs a
149-
``NotSupportedLinqExpression`` warning.
149+
``MALinq2001`` warning.
150150

151-
Click the following tabs to see a code snippet containing an unsupported LINQ expression
152-
and the corresponding warning message displayed by the {+product-short+}:
151+
The following code snippet contains the unsupported ``GetHashCode`` LINQ
152+
expression:
153153

154-
.. tabs::
155-
156-
.. tab:: Code Snippet
157-
:tabid: code-snippet
158-
159-
The following code snippet contains the unsupported ``GetHashCode`` LINQ expression:
160-
161-
.. code-block:: csharp
162-
163-
var result = queryableColl.Where(b => b.GetHashCode() == 167);
164-
165-
The following screenshot shows the annotation displayed by the {+product-short+}
166-
underneath the preceding code snippet in Visual Studio:
167-
168-
.. figure:: /includes/images/linq-unsupported.png
169-
:alt: Screenshot of annotation beneath unsupported LINQ expression
154+
.. code-block:: csharp
170155

171-
.. tab:: Warning
172-
:tabid: warning
156+
var result = queryableColl.Where(b => b.GetHashCode() == 167);
173157

174-
The following is the warning generated by the {+product-short+}:
158+
The {+product-short+} shows an annotation on the unsupported expression
159+
and generates the following warning message:
175160

176-
.. code-block:: text
177-
:copyable: false
161+
.. code-block:: text
162+
:copyable: false
178163

179-
Expression not supported: b.GetHashCode().
164+
Expression not supported: b.GetHashCode().
180165

181-
The following screenshot shows the warning displayed in Visual Studio:
166+
The following screenshot shows the annotated code and the warning
167+
displayed when you hover over the annotation:
182168

183-
.. figure:: /includes/images/linq-unsupported-popup.png
184-
:alt: Screenshot of warning displayed in Visual Studio from unsupported LINQ.
169+
.. figure:: /includes/images/linq-unsupported-popup.png
170+
:alt: Screenshot of warning displayed in Visual Studio from unsupported LINQ.
185171

186172
.. include:: /includes/error-list-window.rst
187173

@@ -225,4 +211,4 @@ provider. To learn how to configure your LINQ provider, see the
225211

226212
To view examples of expressions the {+driver-short+} only supports with the LINQ3 provider, see the
227213
`{+product+} Github repository
228-
<{+product-source-repo+}/blob/main/tests/MongoDB.Analyzer.Tests.Common.TestCases/Linq/NotSupportedLinq2.cs>`__.
214+
<{+product-source-repo+}/blob/main/tests/MongoDB.Analyzer.Tests.Common.TestCases/Linq/NotSupportedLinq2.cs>`__.

source/includes/error-list-window.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.. tip:: Error List Panel
22

33
If you are using Visual Studio for Windows, you can view the output
4-
from the {+product+-short} in the Error List window.
4+
from the {+product-short+} in the Error List window.
55

66
To learn more, see
77
`Error List Window <https://docs.microsoft.com/en-us/visualstudio/ide/reference/error-list-window?view=vs-2022>`__
8-
from Microsoft.
8+
from Microsoft.
Loading
-30.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)