Skip to content

Commit 884eb8f

Browse files
authored
Restructure mockup (#25)
* test 1 * toc landing page fix
1 parent a4fa9cc commit 884eb8f

File tree

5 files changed

+337
-293
lines changed

5 files changed

+337
-293
lines changed

snooty.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name = "visual-studio-extension"
22
title = "MongoDB Analyzer"
3+
toc_landing_pages = [
4+
"/analyze-code",
5+
]
36

47
[constants]
58
product = "MongoDB Analyzer"

source/analyze-code.txt

Lines changed: 10 additions & 292 deletions
Original file line numberDiff line numberDiff line change
@@ -12,304 +12,22 @@ Analyze Your Code
1212
:depth: 2
1313
:class: singlecol
1414

15+
.. toctree::
16+
17+
/code-type/builders
18+
/code-type/linq
19+
1520
Overview
1621
--------
1722

1823
Learn how to use the {+product+} to analyze your {+driver-long+} code.
19-
The {+product+} can analyze **builder** and **Language Integrated Query (LINQ)** expressions.
20-
21-
A builder is a class provided by the {+driver-short+} to help you construct
22-
common operations like queries and updates.
23-
24-
LINQ is a query syntax included in the C# language. The {+driver-short+}
25-
can translate a subset of LINQ expressions into MongoDB aggregation pipelines.
26-
27-
To learn more about builders, see
28-
`Builders <{+driver-docs+}reference/driver/definitions/>`__ in the
29-
{+driver-short+} documentation.
30-
31-
To learn more about LINQ, see the following resources:
32-
33-
- `LINQ <{+driver-docs+}reference/driver/crud/linq/>`__ in the {+driver-short+}
34-
documentation
35-
- `LINQ <https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/>`__
36-
in the Microsoft C# guide
37-
38-
To learn more about aggregation pipelines, see
39-
:manual:`Aggregation </aggregation/>` in the MongoDB manual.
40-
41-
.. note:: Runtime Differences
42-
43-
Although the {+query-api+} translations generated by the {+product+} have the same
44-
:manual:`query shape </reference/glossary/#std-term-query-shape>`
45-
as your runtime {+driver-short+}
46-
queries, there may be slight differences due to the following
47-
factors:
48-
49-
- Your Serialization Settings
50-
- Your LINQ Settings
51-
52-
The difference between the translations the {+product+} generates
53-
and your queries at runtime should not impact your ability to analyze
54-
and debug your code.
55-
56-
To learn more about serialization and LINQ settings, see the
57-
:ref:`FAQ <mongodb-analyzer-faq-custom-serialization>`
58-
page.
59-
60-
.. We use this anchor in a DocHub link
61-
62-
.. _mongodb-analyzer-analyze-builders:
63-
64-
Analyze Builders
65-
----------------
66-
67-
Use the {+product+} to translate your builder expressions into the {+query-api+}.
68-
Click the following tabs to see an example of a builder expression
69-
and its corresponding {+query-api+} translation:
70-
71-
.. tabs::
72-
73-
.. tab:: Builders
74-
:tabid: builder
75-
76-
.. code-block:: csharp
77-
78-
var filter = Builders<Movie>.Filter.Eq(m => m.Genre, genre) &
79-
Builders<Movie>.Filter.Gte(m => m.Score, minScore) &
80-
Builders<Movie>.Filter.Regex(m => m.Score, titleSearchTerm);
81-
82-
.. tab:: {+query-api+}
83-
:tabid: query-api-builders
84-
85-
.. code-block:: json
86-
87-
{
88-
"$and": [ { "Genre": genre },
89-
{ "Score": { "$gte": minScore } },
90-
{ "Score": /titleSearchTerm/ } ]
91-
}
92-
93-
.. include:: /includes/variable-names.rst
94-
95-
Analyze Builders in Visual Studio
96-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
97-
98-
To analyze your builder expressions in Visual Studio, perform the following actions:
99-
100-
1. Install the {+product+} as described in the :ref:`Install <mongodb-analyzer-install>`
101-
guide.
102-
#. Write a builder expression with the {+driver-short+}
103-
#. Move your mouse over the :guilabel:`...` annotation beneath the first
104-
method of your builder expression to display an information message that contains
105-
the {+query-api+} translation.
106-
107-
Click the following tabs to see a builder expression with and without an
108-
information message displayed:
109-
110-
.. tabs::
111-
112-
.. tab:: Without Information Message
113-
:tabid: no-message
114-
115-
.. figure:: /includes/images/builder.png
116-
:alt: Screenshot of builder expression in visual studio with ellipsis annotation.
117-
118-
.. tab:: With Information Message
119-
:tabid: message
120-
121-
.. figure:: /includes/images/builder-popup-photoshop.png
122-
:alt: Screenshot of builder expression in visual studio with information message displayed.
123-
124-
The {+product+} supports builder variable tracking and composition. You can
125-
combine multiple builder expressions with `logical operators
126-
<https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/boolean-logical-operators>`__
127-
and view the {+query-api+} translation in the information message.
128-
129-
Click the following tabs to see a composed builder variable with and without an
130-
information message displayed:
131-
132-
.. tabs::
133-
134-
.. tab:: Without Information Message
135-
:tabid: no-message-variable
136-
137-
.. figure:: /includes/images/builder-variable.png
138-
:alt: Screenshot of builder expression variable in visual studio with ellipsis annotation.
139-
140-
.. tab:: With Information Message
141-
:tabid: message-variable
142-
143-
.. figure:: /includes/images/builder-variable-popup.png
144-
:alt: Screenshot of builder expression variable in visual studio with information message displayed.
145-
146-
.. include:: /includes/error-list-window.rst
147-
148-
.. We use this anchor in a DocHub link
149-
150-
.. _mongodb-analyzer-analyze-linq:
151-
152-
Analyze LINQ
153-
------------
154-
155-
Use the {+product+} to learn the following
156-
about your LINQ expressions:
157-
158-
- How your LINQ expressions translate into the {+query-api+}
159-
- If any of your LINQ expressions are not supported
160-
161-
Click the following tabs to see an example of a LINQ expression
162-
and its corresponding {+query-api+} translation:
163-
164-
.. tabs::
165-
166-
.. tab:: LINQ
167-
:tabid: linq
24+
The {+product+} can analyze expressions created with the following frameworks:
16825

169-
.. code-block:: csharp
170-
171-
var movies = await moviesCollection.Where(m =>
172-
m.Genre == genre &&
173-
m.Score >= minScore &&
174-
m.Title.Contains(titleSearchTerm)).
175-
OrderBy(m => m.Score).
176-
ToListAsync();
177-
178-
.. tab:: {+query-api+}
179-
:tabid: query-api-linq
180-
181-
.. code-block:: json
182-
183-
[{ "$match" : {
184-
"Genre" : genre,
185-
"Score" : { "$gte" : minScore },
186-
"Title" : /titleSearchTerm/s }
187-
},
188-
{ "$sort" : { "Score" : 1 } }]
189-
190-
.. include:: /includes/variable-names.rst
191-
192-
Analyze LINQ in Visual Studio
193-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
194-
195-
To analyze your LINQ expressions in Visual Studio, perform the following actions:
196-
197-
1. Install the {+product+} as described in the :ref:`Install <mongodb-analyzer-install>`
198-
guide.
199-
#. Write a LINQ expression with the {+driver-short+}.
200-
#. Move your mouse over the :guilabel:`...` annotation beneath the first
201-
method of your LINQ expression to display an information message that contains
202-
the {+query-api+} translation.
203-
204-
Click the following tabs to see a LINQ expression with and without an information message
205-
displayed:
206-
207-
.. tabs::
208-
209-
.. tab:: Without Information Message
210-
:tabid: without-message
211-
212-
.. figure:: /includes/images/linq.png
213-
:alt: Screenshot of builder expression in visual studio with ellipsis annotation.
214-
215-
.. tab:: With Information Message
216-
:tabid: with-message
217-
218-
.. figure:: /includes/images/linq-popup.png
219-
:alt: Screenshot of builder expression in visual studio with information message displayed.
220-
221-
.. We use this anchor in a DocHub link
222-
223-
.. _mongodb-analyzer-unsupported-linq:
224-
225-
If your LINQ expression is not supported, the {+product+} outputs a
226-
``NotSupportedLinqExpression`` warning.
227-
228-
Click the following tabs to see a code snippet containing an unsupported LINQ expression
229-
and the corresponding warning message displayed by the {+product+}:
230-
231-
.. tabs::
232-
233-
.. tab:: Code Snippet
234-
:tabid: code-snippet
235-
236-
The following code snippet contains the unsupported ``GetHashCode`` LINQ expression:
237-
238-
.. code-block:: csharp
239-
240-
_ = moviesCollection.Where(m => m.GetHashCode() == 1234);
241-
242-
The following screenshot shows the annotation displayed by the {+product+}
243-
underneath the preceding code snippet in Visual Studio:
244-
245-
.. figure:: /includes/images/linq-unsupported.png
246-
:alt: Screenshot of annotation beneath unsupported LINQ expression
247-
248-
.. tab:: Warning
249-
:tabid: warning
250-
251-
The following is the warning generated by the {+product+}:
252-
253-
.. code-block:: text
254-
:copyable: false
255-
256-
NotSupportedLinqExpression C# {document}.GetHashCode() is not supported.
257-
258-
The following screenshot shows the warning displayed in Visual Studio:
259-
260-
.. figure:: /includes/images/linq-unsupported-popup.png
261-
:alt: Screenshot of warning displayed in Visual Studio from unsupported LINQ.
262-
263-
.. include:: /includes/error-list-window.rst
264-
265-
To view more examples of unsupported LINQ expressions, see the
266-
`{+product+} Github repository <{+product-source-repo+}/tests/MongoDB.Analyzer.Tests.Common.TestCases/Linq/NotSupportedLinqExpressionsBasicTestCases.cs>`__.
267-
268-
.. We use this anchor in a DocHub link
269-
270-
.. _mongodb-analyzer-analyze-linq3:
271-
272-
Analyze LINQ3
273-
~~~~~~~~~~~~~
274-
275-
To analyze a LINQ3 expression, you must configure the {+product+} to use the LINQ3
276-
provider. To learn how to configure your LINQ provider, see the
277-
:ref:`configuration <mongodb-analyzer-configuration>` guide.
278-
279-
.. important:: Expressions Supported Only by LINQ3
280-
281-
If your {+driver-short+} version supports LINQ3 but you configure your {+product+} to use
282-
the default LINQ provider (LINQ2), the {+product+} informs you if your LINQ expression
283-
is supported by LINQ3 but not LINQ2.
284-
285-
Click the tabs to see a LINQ expression supported by LINQ3 but not LINQ2 and the
286-
corresponding warning output by the {+product+}:
287-
288-
.. tabs::
289-
290-
.. tab:: Code Snippet
291-
:tabid: code-snippet-linq3
292-
293-
.. code-block:: csharp
294-
295-
_ = moviesCollection.Where(m => m.Producer.Substring(0, 6) == "Steven")
296-
297-
.. tab:: Warning
298-
:tabid: warning-linq3
299-
300-
.. code-block:: text
301-
:copyable: false
302-
303-
NotSupportedLinq2Expression Supported in LINQ3 only: db.coll.Aggregate([{ "$match" : { "$expr" : { "$eq" : [{ "$substrCP" : ["$Producer", 0, 6] }, "Steven"] } } }])
304-
305-
To learn more about LINQ3, see `LINQ3 <{+driver-docs+}reference/driver/crud/linq3/>`__
306-
in the {+driver-short+} documentation.
307-
308-
To view examples of expressions the {+driver-short+} only supports with the LINQ3 provider, see the
309-
`{+product+} Github repository <{+product-source-repo+}/tests/MongoDB.Analyzer.Tests.Common.TestCases/Linq/NotSupportedLinq2TestCases.cs>`__.
26+
- :ref:`Builders Class <mongodb-analyzer-analyze-builders>`
27+
- :ref:`Language Integrated Query (LINQ) <mongodb-analyzer-analyze-linq>`
31028

31129
Use the {+product+} From the Command Line
312-
----------------------------------------------
30+
-----------------------------------------
31331

31432
To run the {+product+} from the command line and save your results to a
31533
:github:`SARIF </microsoft/sarif-tutorials/blob/main/docs/1-Introduction.md>`
@@ -328,4 +46,4 @@ from Microsoft.
32846

32947
To learn more about the ``ErrorLog`` setting, see
33048
`Error and Warning Options <https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/errors-warnings#errorlog>`__
331-
from Microsoft.
49+
from Microsoft.

0 commit comments

Comments
 (0)