├── .github
├── FUNDING.yml
└── workflows
│ └── build.yaml
├── .gitignore
├── Directory.Build.props
├── LICENSE
├── README.md
├── example.png
├── nuget.config
└── src
├── .editorconfig
├── AnalyticsConfig.cs
├── BaseOptionModel.cs
├── CSInlineColorViz.Tests
├── AllTaggersTests.cs
├── BaseTaggerTests.cs
├── CSInlineColorViz.Tests.csproj
├── Color32TaggerTests.cs
├── ColorCtorTaggerTests.cs
├── ColorFromArgbTaggerTests.cs
├── ColorListHelperTests.cs
├── FakeTextBuffer.cs
├── FunColorTaggerTests.cs
├── Properties
│ └── AssemblyInfo.cs
├── SvgTaggerTests.cs
├── TaggerTestHelper.cs
└── UnityTaggerTests.cs
├── Color32Tagger.cs
├── Color32TaggerProvider.cs
├── ColorAdornment.cs
├── ColorAdornmentTagger.cs
├── ColorAdornmentTaggerProvider.cs
├── ColorArgbTagger.cs
├── ColorArgbTaggerProvider.cs
├── ColorCtorTagger.cs
├── ColorCtorTaggerProvider.cs
├── ColorFromIntTagger.cs
├── ColorFromIntTaggerProvider.cs
├── ColorFromNameTagger.cs
├── ColorFromNameTaggerProvider.cs
├── ColorHslaTagger.cs
├── ColorHslaTaggerProvider.cs
├── ColorHsvaTagger.cs
├── ColorHsvaTaggerProvider.cs
├── ColorListHelper.cs
├── ColorRgbTagger.cs
├── ColorRgbTaggerProvider.cs
├── ColorRgbaTagger.cs
├── ColorRgbaTaggerProvider.cs
├── ColorSelectionDialog.cs
├── ColorTag.cs
├── ColorTagger.cs
├── ColorTaggerProvider.cs
├── ConsoleColorDialog.cs
├── CsInlineColorViz.csproj
├── CsInlineColorViz.sln
├── CsInlineColorVizPackage.cs
├── FunColorTagger.cs
├── FunColorTaggerProvider.cs
├── FunColorsDialog.cs
├── HexIntTagger.cs
├── HexIntTaggerProvider.cs
├── HexStringTagger.cs
├── HexStringTaggerProvider.cs
├── ITestableRegexColorTagger.cs
├── InternalSettings.cs
├── IntraTextAdornmentTagger.cs
├── KnownColorDialog.cs
├── LICENSE.txt
├── MauiProjTagger.cs
├── MauiProjTaggerProvider.cs
├── NamedColorDialog.cs
├── OutlineTextControl.cs
├── OutputPane.cs
├── PopupType.cs
├── Properties
└── AssemblyInfo.cs
├── RegexTagger.cs
├── Resources
└── Icon.png
├── SponsorDetector.cs
├── SponsorRequestHelper.cs
├── SvgTagger.cs
├── SvgTaggerProvider.cs
├── SystemColorsDialog.cs
├── TextDocumentHelper.cs
├── UnityColorsDialog.cs
├── UnityTagger.cs
├── UnityTaggerProvider.cs
├── UnityTextTagger.cs
├── UnityTextTaggerProvider.cs
├── filestosign.txt
├── signvsix.targets
├── source.extension.cs
└── source.extension.vsixmanifest
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: mrlacey # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
12 | polar: # Replace with a single Polar username
13 | buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
14 | thanks_dev: # Replace with a single thanks.dev username
15 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
16 |
--------------------------------------------------------------------------------
/.github/workflows/build.yaml:
--------------------------------------------------------------------------------
1 | # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2 | name: "Build"
3 |
4 | on:
5 | push:
6 | branches: [main]
7 | paths-ignore:
8 | - '*.md'
9 | pull_request:
10 | branches: [main]
11 | paths-ignore:
12 | - '*.md'
13 |
14 | jobs:
15 | build:
16 | outputs:
17 | version: ${{ steps.vsix_version.outputs.version-number }}
18 | name: Build
19 | runs-on: windows-2022
20 | env:
21 | Configuration: Debug
22 | DeployExtension: False
23 | VsixManifestPath: src\source.extension.vsixmanifest
24 | VsixManifestSourcePath: src\source.extension.cs
25 |
26 | steps:
27 | - uses: actions/checkout@v4
28 |
29 | - name: Setup .NET build dependencies
30 | uses: timheuer/bootstrap-dotnet@v2
31 | with:
32 | nuget: 'false'
33 | sdk: 'false'
34 | msbuild: 'true'
35 |
36 | - name: Increment VSIX version
37 | id: vsix_version
38 | uses: timheuer/vsix-version-stamp@v2
39 | with:
40 | manifest-file: ${{ env.VsixManifestPath }}
41 | vsix-token-source-file: ${{ env.VsixManifestSourcePath }}
42 |
43 | - name: Build
44 | run: msbuild /v:m -restore /p:OutDir=\_built ./src/CsInlineColorViz.sln
45 |
46 | - name: Upload artifact
47 | uses: actions/upload-artifact@v4
48 | with:
49 | name: ${{ github.event.repository.name }}.vsix
50 | path: /_built/**/*.vsix
51 |
52 | - name: Run Tests
53 | # See https://github.com/microsoft/vstest-action/issues/31
54 | # uses: microsoft/vstest-action@v1.0.0
55 | uses: josepho0918/vstest-action@main
56 | with:
57 | searchFolder: /_built/
58 | testAssembly: /**/*Tests.dll
59 |
60 | - name: Publish Test Results
61 | uses: EnricoMi/publish-unit-test-result-action/windows@v2
62 | id: test-results
63 | with:
64 | files: testresults\**\*.trx
65 |
66 | - name: Set badge color
67 | shell: bash
68 | run: |
69 | case ${{ fromJSON( steps.test-results.outputs.json ).conclusion }} in
70 | success)
71 | echo "BADGE_COLOR=31c653" >> $GITHUB_ENV
72 | ;;
73 | failure)
74 | echo "BADGE_COLOR=800000" >> $GITHUB_ENV
75 | ;;
76 | neutral)
77 | echo "BADGE_COLOR=696969" >> $GITHUB_ENV
78 | ;;
79 | esac
80 |
81 | - name: Create badge
82 | uses: emibcn/badge-action@808173dd03e2f30c980d03ee49e181626088eee8
83 | with:
84 | label: Tests
85 | status: '${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.tests }} tests: ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}'
86 | color: ${{ env.BADGE_COLOR }}
87 | path: CSInlineColorViz.badge.svg
88 |
89 | - name: Upload badge to Gist
90 | # Upload only for main branch
91 | if: >
92 | github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main' ||
93 | github.event_name != 'workflow_run' && github.ref == 'refs/heads/main'
94 | uses: andymckay/append-gist-action@6e8d64427fe47cbacf4ab6b890411f1d67c07f3e
95 | with:
96 | token: ${{ secrets.GIST_TOKEN }}
97 | gistURL: https://gist.githubusercontent.com/mrlacey/c586ff0f495b4a8dd76ab0dbdf9c89e0
98 | file: CSInlineColorViz.badge.svg
99 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # TeamCity is a build add-in
131 | _TeamCity*
132 |
133 | # DotCover is a Code Coverage Tool
134 | *.dotCover
135 |
136 | # AxoCover is a Code Coverage Tool
137 | .axoCover/*
138 | !.axoCover/settings.json
139 |
140 | # Visual Studio code coverage results
141 | *.coverage
142 | *.coveragexml
143 |
144 | # NCrunch
145 | _NCrunch_*
146 | .*crunch*.local.xml
147 | nCrunchTemp_*
148 |
149 | # MightyMoose
150 | *.mm.*
151 | AutoTest.Net/
152 |
153 | # Web workbench (sass)
154 | .sass-cache/
155 |
156 | # Installshield output folder
157 | [Ee]xpress/
158 |
159 | # DocProject is a documentation generator add-in
160 | DocProject/buildhelp/
161 | DocProject/Help/*.HxT
162 | DocProject/Help/*.HxC
163 | DocProject/Help/*.hhc
164 | DocProject/Help/*.hhk
165 | DocProject/Help/*.hhp
166 | DocProject/Help/Html2
167 | DocProject/Help/html
168 |
169 | # Click-Once directory
170 | publish/
171 |
172 | # Publish Web Output
173 | *.[Pp]ublish.xml
174 | *.azurePubxml
175 | # Note: Comment the next line if you want to checkin your web deploy settings,
176 | # but database connection strings (with potential passwords) will be unencrypted
177 | *.pubxml
178 | *.publishproj
179 |
180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
181 | # checkin your Azure Web App publish settings, but sensitive information contained
182 | # in these scripts will be unencrypted
183 | PublishScripts/
184 |
185 | # NuGet Packages
186 | *.nupkg
187 | # NuGet Symbol Packages
188 | *.snupkg
189 | # The packages folder can be ignored because of Package Restore
190 | **/[Pp]ackages/*
191 | # except build/, which is used as an MSBuild target.
192 | !**/[Pp]ackages/build/
193 | # Uncomment if necessary however generally it will be regenerated when needed
194 | #!**/[Pp]ackages/repositories.config
195 | # NuGet v3's project.json files produces more ignorable files
196 | *.nuget.props
197 | *.nuget.targets
198 |
199 | # Microsoft Azure Build Output
200 | csx/
201 | *.build.csdef
202 |
203 | # Microsoft Azure Emulator
204 | ecf/
205 | rcf/
206 |
207 | # Windows Store app package directories and files
208 | AppPackages/
209 | BundleArtifacts/
210 | Package.StoreAssociation.xml
211 | _pkginfo.txt
212 | *.appx
213 | *.appxbundle
214 | *.appxupload
215 |
216 | # Visual Studio cache files
217 | # files ending in .cache can be ignored
218 | *.[Cc]ache
219 | # but keep track of directories ending in .cache
220 | !?*.[Cc]ache/
221 |
222 | # Others
223 | ClientBin/
224 | ~$*
225 | *~
226 | *.dbmdl
227 | *.dbproj.schemaview
228 | *.jfm
229 | *.pfx
230 | *.publishsettings
231 | orleans.codegen.cs
232 |
233 | # Including strong name files can present a security risk
234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
235 | #*.snk
236 |
237 | # Since there are multiple workflows, uncomment next line to ignore bower_components
238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
239 | #bower_components/
240 |
241 | # RIA/Silverlight projects
242 | Generated_Code/
243 |
244 | # Backup & report files from converting an old project file
245 | # to a newer Visual Studio version. Backup files are not needed,
246 | # because we have git ;-)
247 | _UpgradeReport_Files/
248 | Backup*/
249 | UpgradeLog*.XML
250 | UpgradeLog*.htm
251 | ServiceFabricBackup/
252 | *.rptproj.bak
253 |
254 | # SQL Server files
255 | *.mdf
256 | *.ldf
257 | *.ndf
258 |
259 | # Business Intelligence projects
260 | *.rdl.data
261 | *.bim.layout
262 | *.bim_*.settings
263 | *.rptproj.rsuser
264 | *- [Bb]ackup.rdl
265 | *- [Bb]ackup ([0-9]).rdl
266 | *- [Bb]ackup ([0-9][0-9]).rdl
267 |
268 | # Microsoft Fakes
269 | FakesAssemblies/
270 |
271 | # GhostDoc plugin setting file
272 | *.GhostDoc.xml
273 |
274 | # Node.js Tools for Visual Studio
275 | .ntvs_analysis.dat
276 | node_modules/
277 |
278 | # Visual Studio 6 build log
279 | *.plg
280 |
281 | # Visual Studio 6 workspace options file
282 | *.opt
283 |
284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
285 | *.vbw
286 |
287 | # Visual Studio LightSwitch build output
288 | **/*.HTMLClient/GeneratedArtifacts
289 | **/*.DesktopClient/GeneratedArtifacts
290 | **/*.DesktopClient/ModelManifest.xml
291 | **/*.Server/GeneratedArtifacts
292 | **/*.Server/ModelManifest.xml
293 | _Pvt_Extensions
294 |
295 | # Paket dependency manager
296 | .paket/paket.exe
297 | paket-files/
298 |
299 | # FAKE - F# Make
300 | .fake/
301 |
302 | # CodeRush personal settings
303 | .cr/personal
304 |
305 | # Python Tools for Visual Studio (PTVS)
306 | __pycache__/
307 | *.pyc
308 |
309 | # Cake - Uncomment if you are using it
310 | # tools/**
311 | # !tools/packages.config
312 |
313 | # Tabs Studio
314 | *.tss
315 |
316 | # Telerik's JustMock configuration file
317 | *.jmconfig
318 |
319 | # BizTalk build output
320 | *.btp.cs
321 | *.btm.cs
322 | *.odx.cs
323 | *.xsd.cs
324 |
325 | # OpenCover UI analysis results
326 | OpenCover/
327 |
328 | # Azure Stream Analytics local run output
329 | ASALocalRun/
330 |
331 | # MSBuild Binary and Structured Log
332 | *.binlog
333 |
334 | # NVidia Nsight GPU debugger configuration file
335 | *.nvuser
336 |
337 | # MFractors (Xamarin productivity tool) working folder
338 | .mfractor/
339 |
340 | # Local History for Visual Studio
341 | .localhistory/
342 |
343 | # BeatPulse healthcheck temp database
344 | healthchecksdb
345 |
346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
347 | MigrationBackup/
348 |
349 | # Ionide (cross platform F# VS Code tools) working folder
350 | .ionide/
351 |
--------------------------------------------------------------------------------
/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 12.0
5 |
6 |
7 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021-2024 Matt Lacey
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # C# Inline Color Visualizer
2 |
3 | 
4 | [](LICENSE)
5 |
6 | [](https://github.com/mrlacey/CSInlineColorViz/actions/workflows/build.yaml)
7 | 
8 |
9 | See samples of the colors you use within your C# code.
10 | Never again be forced to remember what a named color looks like or work out what color a HEX value represents.
11 |
12 | 
13 |
14 | Works with `*.cs`, `*.cshtml`, and `*.razor` files.
15 |
--------------------------------------------------------------------------------
/example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrlacey/CSInlineColorViz/15142ec27948ef6135379acc7594ce77137a810d/example.png
--------------------------------------------------------------------------------
/nuget.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/.editorconfig:
--------------------------------------------------------------------------------
1 | # Remove the line below if you want to inherit .editorconfig settings from higher directories
2 | root = true
3 |
4 | # C# files
5 | [*.cs]
6 |
7 | #### Core EditorConfig Options ####
8 |
9 | # Indentation and spacing
10 | indent_size = 4
11 | indent_style = tab
12 | tab_width = 4
13 |
14 | # New line preferences
15 | end_of_line = crlf
16 | insert_final_newline = false
17 |
18 | #### .NET Coding Conventions ####
19 |
20 | # Organize usings
21 | dotnet_separate_import_directive_groups = false
22 | dotnet_sort_system_directives_first = true
23 | file_header_template = unset
24 |
25 | # this. and Me. preferences
26 | dotnet_style_qualification_for_event = false
27 | dotnet_style_qualification_for_field = false
28 | dotnet_style_qualification_for_method = false
29 | dotnet_style_qualification_for_property = false
30 |
31 | # Language keywords vs BCL types preferences
32 | dotnet_style_predefined_type_for_locals_parameters_members = true
33 | dotnet_style_predefined_type_for_member_access = true
34 |
35 | # Parentheses preferences
36 | dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity
37 | dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
38 | dotnet_style_parentheses_in_other_operators = never_if_unnecessary
39 | dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
40 |
41 | # Modifier preferences
42 | dotnet_style_require_accessibility_modifiers = for_non_interface_members
43 |
44 | # Expression-level preferences
45 | dotnet_style_coalesce_expression = true
46 | dotnet_style_collection_initializer = true
47 | dotnet_style_explicit_tuple_names = true
48 | dotnet_style_namespace_match_folder = true
49 | dotnet_style_null_propagation = true
50 | dotnet_style_object_initializer = true
51 | dotnet_style_operator_placement_when_wrapping = beginning_of_line
52 | dotnet_style_prefer_auto_properties = true
53 | dotnet_style_prefer_collection_expression = when_types_loosely_match
54 | dotnet_style_prefer_compound_assignment = true
55 | dotnet_style_prefer_conditional_expression_over_assignment = true
56 | dotnet_style_prefer_conditional_expression_over_return = true
57 | dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed
58 | dotnet_style_prefer_inferred_anonymous_type_member_names = true
59 | dotnet_style_prefer_inferred_tuple_names = true
60 | dotnet_style_prefer_is_null_check_over_reference_equality_method = true
61 | dotnet_style_prefer_simplified_boolean_expressions = true
62 | dotnet_style_prefer_simplified_interpolation = true
63 |
64 | # Field preferences
65 | dotnet_style_readonly_field = true
66 |
67 | # Parameter preferences
68 | dotnet_code_quality_unused_parameters = all
69 |
70 | # Suppression preferences
71 | dotnet_remove_unnecessary_suppression_exclusions = none
72 |
73 | # New line preferences
74 | dotnet_style_allow_multiple_blank_lines_experimental = true
75 | dotnet_style_allow_statement_immediately_after_block_experimental = true
76 |
77 | #### C# Coding Conventions ####
78 |
79 | # var preferences
80 | csharp_style_var_elsewhere = false
81 | csharp_style_var_for_built_in_types = false
82 | csharp_style_var_when_type_is_apparent = false
83 |
84 | # Expression-bodied members
85 | csharp_style_expression_bodied_accessors = true
86 | csharp_style_expression_bodied_constructors = false
87 | csharp_style_expression_bodied_indexers = true
88 | csharp_style_expression_bodied_lambdas = true
89 | csharp_style_expression_bodied_local_functions = false
90 | csharp_style_expression_bodied_methods = false
91 | csharp_style_expression_bodied_operators = false
92 | csharp_style_expression_bodied_properties = true
93 |
94 | # Pattern matching preferences
95 | csharp_style_pattern_matching_over_as_with_null_check = true
96 | csharp_style_pattern_matching_over_is_with_cast_check = true
97 | csharp_style_prefer_extended_property_pattern = true
98 | csharp_style_prefer_not_pattern = true
99 | csharp_style_prefer_pattern_matching = true
100 | csharp_style_prefer_switch_expression = true
101 |
102 | # Null-checking preferences
103 | csharp_style_conditional_delegate_call = true
104 |
105 | # Modifier preferences
106 | csharp_prefer_static_local_function = true
107 | csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async
108 | csharp_style_prefer_readonly_struct = true
109 | csharp_style_prefer_readonly_struct_member = true
110 |
111 | # Code-block preferences
112 | csharp_prefer_braces = true
113 | csharp_prefer_simple_using_statement = true
114 | csharp_style_namespace_declarations = block_scoped
115 | csharp_style_prefer_method_group_conversion = true
116 | csharp_style_prefer_primary_constructors = true
117 | csharp_style_prefer_top_level_statements = true
118 |
119 | # Expression-level preferences
120 | csharp_prefer_simple_default_expression = true
121 | csharp_style_deconstructed_variable_declaration = true
122 | csharp_style_implicit_object_creation_when_type_is_apparent = true
123 | csharp_style_inlined_variable_declaration = true
124 | csharp_style_prefer_index_operator = true
125 | csharp_style_prefer_local_over_anonymous_function = true
126 | csharp_style_prefer_null_check_over_type_check = true
127 | csharp_style_prefer_range_operator = true
128 | csharp_style_prefer_tuple_swap = true
129 | csharp_style_prefer_utf8_string_literals = true
130 | csharp_style_throw_expression = true
131 | csharp_style_unused_value_assignment_preference = discard_variable
132 | csharp_style_unused_value_expression_statement_preference = discard_variable
133 |
134 | # 'using' directive preferences
135 | csharp_using_directive_placement = outside_namespace
136 |
137 | # New line preferences
138 | csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true
139 | csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true
140 | csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true
141 | csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true
142 | csharp_style_allow_embedded_statements_on_same_line_experimental = true
143 |
144 | #### C# Formatting Rules ####
145 |
146 | # New line preferences
147 | csharp_new_line_before_catch = true
148 | csharp_new_line_before_else = true
149 | csharp_new_line_before_finally = true
150 | csharp_new_line_before_members_in_anonymous_types = true
151 | csharp_new_line_before_members_in_object_initializers = true
152 | csharp_new_line_before_open_brace = all
153 | csharp_new_line_between_query_expression_clauses = true
154 |
155 | # Indentation preferences
156 | csharp_indent_block_contents = true
157 | csharp_indent_braces = false
158 | csharp_indent_case_contents = true
159 | csharp_indent_case_contents_when_block = true
160 | csharp_indent_labels = one_less_than_current
161 | csharp_indent_switch_labels = true
162 |
163 | # Space preferences
164 | csharp_space_after_cast = false
165 | csharp_space_after_colon_in_inheritance_clause = true
166 | csharp_space_after_comma = true
167 | csharp_space_after_dot = false
168 | csharp_space_after_keywords_in_control_flow_statements = true
169 | csharp_space_after_semicolon_in_for_statement = true
170 | csharp_space_around_binary_operators = before_and_after
171 | csharp_space_around_declaration_statements = false
172 | csharp_space_before_colon_in_inheritance_clause = true
173 | csharp_space_before_comma = false
174 | csharp_space_before_dot = false
175 | csharp_space_before_open_square_brackets = false
176 | csharp_space_before_semicolon_in_for_statement = false
177 | csharp_space_between_empty_square_brackets = false
178 | csharp_space_between_method_call_empty_parameter_list_parentheses = false
179 | csharp_space_between_method_call_name_and_opening_parenthesis = false
180 | csharp_space_between_method_call_parameter_list_parentheses = false
181 | csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
182 | csharp_space_between_method_declaration_name_and_open_parenthesis = false
183 | csharp_space_between_method_declaration_parameter_list_parentheses = false
184 | csharp_space_between_parentheses = false
185 | csharp_space_between_square_brackets = false
186 |
187 | # Wrapping preferences
188 | csharp_preserve_single_line_blocks = true
189 | csharp_preserve_single_line_statements = true
190 |
191 | #### Naming styles ####
192 |
193 | # Naming rules
194 |
195 | dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
196 | dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
197 | dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
198 |
199 | dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
200 | dotnet_naming_rule.types_should_be_pascal_case.symbols = types
201 | dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
202 |
203 | dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
204 | dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
205 | dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
206 |
207 | # Symbol specifications
208 |
209 | dotnet_naming_symbols.interface.applicable_kinds = interface
210 | dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
211 | dotnet_naming_symbols.interface.required_modifiers =
212 |
213 | dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
214 | dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
215 | dotnet_naming_symbols.types.required_modifiers =
216 |
217 | dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
218 | dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
219 | dotnet_naming_symbols.non_field_members.required_modifiers =
220 |
221 | # Naming styles
222 |
223 | dotnet_naming_style.pascal_case.required_prefix =
224 | dotnet_naming_style.pascal_case.required_suffix =
225 | dotnet_naming_style.pascal_case.word_separator =
226 | dotnet_naming_style.pascal_case.capitalization = pascal_case
227 |
228 | dotnet_naming_style.begins_with_i.required_prefix = I
229 | dotnet_naming_style.begins_with_i.required_suffix =
230 | dotnet_naming_style.begins_with_i.word_separator =
231 | dotnet_naming_style.begins_with_i.capitalization = pascal_case
232 |
--------------------------------------------------------------------------------
/src/AnalyticsConfig.cs:
--------------------------------------------------------------------------------
1 | namespace CsInlineColorViz
2 | {
3 | public static class AnalyticsConfig
4 | {
5 | public static string TelemetryConnectionString { get; set; } = "";
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/BaseOptionModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Reflection;
6 | using System.Runtime.Serialization.Formatters.Binary;
7 | using System.Threading.Tasks;
8 | using Microsoft;
9 | using Microsoft.VisualStudio.Settings;
10 | using Microsoft.VisualStudio.Shell;
11 | using Microsoft.VisualStudio.Shell.Interop;
12 | using Microsoft.VisualStudio.Shell.Settings;
13 | using Microsoft.VisualStudio.Threading;
14 | using Task = System.Threading.Tasks.Task;
15 |
16 | namespace CsInlineColorViz
17 | {
18 | ///
19 | /// A base class for specifying options.
20 | /// From https://github.com/microsoft/VSSDK-Extensibility-Samples/blob/master/Options/src/Options/BaseOptionModel.cs
21 | ///
22 | internal abstract class BaseOptionModel where T : BaseOptionModel, new()
23 | {
24 | private static readonly AsyncLazy _liveModel = new(CreateAsync, ThreadHelper.JoinableTaskFactory);
25 | private static readonly AsyncLazy _settingsManager = new(GetSettingsManagerAsync, ThreadHelper.JoinableTaskFactory);
26 |
27 | protected BaseOptionModel()
28 | { }
29 |
30 | ///
31 | /// A singleton instance of the options. MUST be called from UI thread only.
32 | ///
33 | ///
34 | /// Call instead if on a background thread or in an async context on the main thread.
35 | ///
36 | public static T Instance
37 | {
38 | get
39 | {
40 | ThreadHelper.ThrowIfNotOnUIThread();
41 |
42 | return ThreadHelper.JoinableTaskFactory.Run(GetLiveInstanceAsync);
43 | }
44 | }
45 |
46 | ///
47 | /// Get the singleton instance of the options. Thread safe.
48 | ///
49 | public static Task GetLiveInstanceAsync() => _liveModel.GetValueAsync();
50 |
51 | ///
52 | /// Creates a new instance of the options class and loads the values from the store. For internal use only
53 | ///
54 | ///
55 | public static async Task CreateAsync()
56 | {
57 | var instance = new T();
58 | await instance.LoadAsync();
59 | return instance;
60 | }
61 |
62 | ///
63 | /// The name of the options collection as stored in the registry.
64 | ///
65 | protected virtual string CollectionName { get; } = typeof(T).FullName;
66 |
67 | ///
68 | /// Hydrates the properties from the registry.
69 | ///
70 | public virtual void Load()
71 | {
72 | ThreadHelper.JoinableTaskFactory.Run(LoadAsync);
73 | }
74 |
75 | ///
76 | /// Hydrates the properties from the registry asyncronously.
77 | ///
78 | public virtual async Task LoadAsync()
79 | {
80 | ShellSettingsManager manager = await _settingsManager.GetValueAsync();
81 | SettingsStore settingsStore = manager.GetReadOnlySettingsStore(SettingsScope.UserSettings);
82 |
83 | if (!settingsStore.CollectionExists(CollectionName))
84 | {
85 | return;
86 | }
87 |
88 | foreach (PropertyInfo property in GetOptionProperties())
89 | {
90 | try
91 | {
92 | string serializedProp = settingsStore.GetString(CollectionName, property.Name);
93 | object value = DeserializeValue(serializedProp, property.PropertyType);
94 | property.SetValue(this, value);
95 | }
96 | catch (Exception ex)
97 | {
98 | System.Diagnostics.Debug.Write(ex);
99 | }
100 | }
101 | }
102 |
103 | ///
104 | /// Saves the properties to the registry.
105 | ///
106 | public virtual void Save()
107 | {
108 | ThreadHelper.JoinableTaskFactory.Run(SaveAsync);
109 | }
110 |
111 | ///
112 | /// Saves the properties to the registry asyncronously.
113 | ///
114 | public virtual async Task SaveAsync()
115 | {
116 | ShellSettingsManager manager = await _settingsManager.GetValueAsync();
117 | WritableSettingsStore settingsStore = manager.GetWritableSettingsStore(SettingsScope.UserSettings);
118 |
119 | if (!settingsStore.CollectionExists(CollectionName))
120 | {
121 | settingsStore.CreateCollection(CollectionName);
122 | }
123 |
124 | foreach (PropertyInfo property in GetOptionProperties())
125 | {
126 | string output = SerializeValue(property.GetValue(this));
127 | settingsStore.SetString(CollectionName, property.Name, output);
128 | }
129 |
130 | T liveModel = await GetLiveInstanceAsync();
131 |
132 | if (this != liveModel)
133 | {
134 | await liveModel.LoadAsync();
135 | }
136 | }
137 |
138 | ///
139 | /// Serializes an object value to a string using the binary serializer.
140 | ///
141 | protected virtual string SerializeValue(object value)
142 | {
143 | using var stream = new MemoryStream();
144 | var formatter = new BinaryFormatter();
145 | formatter.Serialize(stream, value);
146 | stream.Flush();
147 | return Convert.ToBase64String(stream.ToArray());
148 | }
149 |
150 | ///
151 | /// Deserializes a string to an object using the binary serializer.
152 | ///
153 | protected virtual object DeserializeValue(string value, Type type)
154 | {
155 | byte[] b = Convert.FromBase64String(value);
156 |
157 | using var stream = new MemoryStream(b);
158 | var formatter = new BinaryFormatter();
159 | return formatter.Deserialize(stream);
160 | }
161 |
162 | private static async Task GetSettingsManagerAsync()
163 | {
164 | #pragma warning disable VSTHRD010
165 | // False-positive in Threading Analyzers. Bug tracked here https://github.com/Microsoft/vs-threading/issues/230
166 | var svc = await AsyncServiceProvider.GlobalProvider.GetServiceAsync(typeof(SVsSettingsManager)) as IVsSettingsManager;
167 | #pragma warning restore VSTHRD010
168 |
169 | Assumes.Present(svc);
170 |
171 | return new ShellSettingsManager(svc);
172 | }
173 |
174 | private IEnumerable GetOptionProperties()
175 | {
176 | return GetType()
177 | .GetProperties()
178 | .Where(p => p.PropertyType.IsSerializable && p.PropertyType.IsPublic);
179 | }
180 | }
181 | }
182 |
--------------------------------------------------------------------------------
/src/CSInlineColorViz.Tests/AllTaggersTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text.RegularExpressions;
3 | using Microsoft.VisualStudio.TestTools.UnitTesting;
4 |
5 | namespace CSInlineColorViz.Tests;
6 |
7 | [TestClass]
8 | public class AllTaggersTests : BaseTaggerTests
9 | {
10 | [DataTestMethod]
11 | [DynamicData(nameof(TaggerTestHelper.AllTaggerRegexs), typeof(TaggerTestHelper), DynamicDataSourceType.Method)]
12 | public void DoesNotMatch_InconsequentialText(Regex type)
13 | {
14 | base.DoesNotMatch_Text(type, "just some inconsequential text string");
15 | }
16 |
17 | [DataTestMethod]
18 | [DynamicData(nameof(TaggerTestHelper.AllTaggerRegexs), typeof(TaggerTestHelper), DynamicDataSourceType.Method)]
19 | public void DoesNotMatch_EmptyString(Regex type)
20 | {
21 | base.DoesNotMatch_Text(type, string.Empty);
22 | }
23 |
24 | [DataTestMethod]
25 | [DynamicData(nameof(TaggerTestHelper.AllTaggerRegexs), typeof(TaggerTestHelper), DynamicDataSourceType.Method)]
26 | public void DoesNotMatch_Whitespace(Regex type)
27 | {
28 | base.DoesNotMatch_Text(type, " ");
29 | }
30 | }
--------------------------------------------------------------------------------
/src/CSInlineColorViz.Tests/BaseTaggerTests.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Text.RegularExpressions;
3 | using Microsoft.VisualStudio.TestTools.UnitTesting;
4 |
5 | namespace CSInlineColorViz.Tests;
6 |
7 | public class BaseTaggerTests
8 | {
9 | public void DoesNotMatch_Text(Regex regex, string text)
10 | {
11 | var matches = regex.Matches(text).Cast();
12 |
13 | Assert.AreEqual(0, matches.Count());
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/CSInlineColorViz.Tests/CSInlineColorViz.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {D3A4F760-435E-4399-81C0-8BADC9C725CD}
8 | Library
9 | Properties
10 | CSInlineColorViz.Tests
11 | CSInlineColorViz.Tests
12 | v4.8.1
13 | 512
14 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
15 | 15.0
16 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
17 | $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
18 | False
19 | UnitTest
20 |
21 |
22 |
23 |
24 |
25 | true
26 | full
27 | false
28 | bin\Debug\
29 | DEBUG;TRACE
30 | prompt
31 | 4
32 |
33 |
34 | pdbonly
35 | true
36 | bin\Release\
37 | TRACE
38 | prompt
39 | 4
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | 4.7.36
62 |
63 |
64 | 3.6.4
65 |
66 |
67 | 3.6.4
68 |
69 |
70 | 3.6.4
71 | runtime; build; native; contentfiles; analyzers; buildtransitive
72 | all
73 |
74 |
75 | 1.7.0
76 | runtime; build; native; contentfiles; analyzers; buildtransitive
77 | all
78 |
79 |
80 |
81 |
82 | {7e6e7299-f72b-4236-b833-b0f2beb4bffd}
83 | CsInlineColorViz
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/src/CSInlineColorViz.Tests/Color32TaggerTests.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Text.RegularExpressions;
3 | using CsInlineColorViz;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 | using Microsoft.VisualStudio.Text.Tagging;
6 |
7 | namespace CSInlineColorViz.Tests;
8 |
9 | // https://docs.unity3d.com/ScriptReference/Color32-ctor.html
10 | [TestClass]
11 | public class Color32TaggerTests : BaseTaggerTests
12 | {
13 | [TestMethod]
14 | public void CanMatchSingleColor()
15 | {
16 | var sut = new Color32Tagger(new FakeTextBuffer());
17 |
18 | Assert.IsNotNull(sut);
19 |
20 | var lineWithColor = "var testValue = new Color32(255, 0, 0, 255)";
21 |
22 | var matches = sut.ColorExpression.Matches(lineWithColor).Cast();
23 |
24 | Assert.AreEqual(1, matches.Count());
25 |
26 | var tag = sut.TryCreateTagForMatch(matches.First(), 0, 0, 0, lineWithColor);
27 |
28 | Assert.IsNotNull(tag);
29 | }
30 |
31 | [TestMethod]
32 | public void CanMatchSingleColor_NoSpaces()
33 | {
34 | var sut = new Color32Tagger(new FakeTextBuffer());
35 |
36 | Assert.IsNotNull(sut);
37 |
38 | var lineWithColor = "var testValue = new Color32(255,0,0,255)";
39 |
40 | var matches = sut.ColorExpression.Matches(lineWithColor).Cast();
41 |
42 | Assert.AreEqual(1, matches.Count());
43 |
44 | var tag = sut.TryCreateTagForMatch(matches.First(), 0, 0, 0, lineWithColor);
45 |
46 | Assert.IsNotNull(tag);
47 | }
48 |
49 | // Not yet supported. Can be added later if people really write code like this.
50 | //[TestMethod]
51 | //public void CanMatchSingleColor_SpacesBeforeCommas()
52 | //{
53 | // var sut = new Color32Tagger(new FakeTextBuffer());
54 |
55 | // Assert.IsNotNull(sut);
56 |
57 | // var lineWithColor = "var testValue = new Color32(255 ,0 ,0 ,255)";
58 |
59 | // var matches = sut.ColorExpression.Matches(lineWithColor).Cast();
60 |
61 | // Assert.AreEqual(1, matches.Count());
62 |
63 | // var tag = sut.TryCreateTagForMatch(matches.First(), 0, 0, 0, lineWithColor);
64 |
65 | // Assert.IsNotNull(tag);
66 | //}
67 | }
68 |
--------------------------------------------------------------------------------
/src/CSInlineColorViz.Tests/ColorCtorTaggerTests.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Text.RegularExpressions;
3 | using CsInlineColorViz;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | namespace CSInlineColorViz.Tests;
7 |
8 | // https://docs.unity3d.com/ScriptReference/Color-ctor.html
9 | [TestClass]
10 | public class ColorCtorTaggerTests : BaseTaggerTests
11 | {
12 | [TestMethod]
13 | public void CanMatchSingleColor_3Bytes()
14 | {
15 | var sut = new ColorCtorTagger(new FakeTextBuffer());
16 |
17 | Assert.IsNotNull(sut);
18 |
19 | var lineWithColor = "var testValue = new Color(255, 0, 0);";
20 |
21 | var matches = sut.ColorExpression.Matches(lineWithColor).Cast();
22 |
23 | Assert.AreEqual(1, matches.Count());
24 |
25 | var tag = sut.TryCreateTagForMatch(matches.First(), 0, 0, 0, lineWithColor);
26 |
27 | Assert.IsNotNull(tag);
28 | }
29 |
30 | [TestMethod]
31 | public void CanMatchSingleColor_3Floats()
32 | {
33 | var sut = new ColorCtorTagger(new FakeTextBuffer());
34 |
35 | Assert.IsNotNull(sut);
36 |
37 | var lineWithColor = "var testValue = new Color(1.0f, 0.0f, 0.0f)";
38 |
39 | var matches = sut.ColorExpression.Matches(lineWithColor).Cast();
40 |
41 | Assert.AreEqual(1, matches.Count());
42 |
43 | var tag = sut.TryCreateTagForMatch(matches.First(), 0, 0, 0, lineWithColor);
44 |
45 | Assert.IsNotNull(tag);
46 | }
47 |
48 | [TestMethod]
49 | public void CanMatchSingleColor_4Floats()
50 | {
51 | var sut = new ColorCtorTagger(new FakeTextBuffer());
52 |
53 | Assert.IsNotNull(sut);
54 |
55 | var lineWithColor = "var testValue = new Color(0.0f, 0.0f, 0.0f, 0.5f)";
56 |
57 | var matches = sut.ColorExpression.Matches(lineWithColor).Cast();
58 |
59 | Assert.AreEqual(1, matches.Count());
60 |
61 | var tag = sut.TryCreateTagForMatch(matches.First(), 0, 0, 0, lineWithColor);
62 |
63 | Assert.IsNotNull(tag);
64 | }
65 | }
66 |
67 | //[TestClass]
68 | //public class FloatColor32TaggerTests : BaseTaggerTests
69 | //{
70 | // [TestMethod]
71 | // public void CanMatchSingleColor_NoDecimals()
72 | // {
73 | // var sut = new Color32Tagger(new FakeTextBuffer());
74 |
75 | // Assert.IsNotNull(sut);
76 |
77 | // var lineWithColor = "var testValue = new Color32(1, 0, 0, 1)";
78 |
79 | // var matches = sut.ColorExpression.Matches(lineWithColor).Cast();
80 |
81 | // Assert.AreEqual(1, matches.Count());
82 |
83 | // var tag = sut.TryCreateTagForMatch(matches.First(), 0, 0, 0, lineWithColor);
84 |
85 | // Assert.IsNotNull(tag);
86 | // }
87 |
88 | // [TestMethod]
89 | // public void CanMatchSingleColor_WithDecimals()
90 | // {
91 | // var sut = new Color32Tagger(new FakeTextBuffer());
92 |
93 | // Assert.IsNotNull(sut);
94 |
95 | // var lineWithColor = "var testValue = new Color32(1.0, 1.0, 0.0, 1.0)";
96 |
97 | // var matches = sut.ColorExpression.Matches(lineWithColor).Cast();
98 |
99 | // Assert.AreEqual(1, matches.Count());
100 |
101 | // var tag = sut.TryCreateTagForMatch(matches.First(), 0, 0, 0, lineWithColor);
102 |
103 | // Assert.IsNotNull(tag);
104 | // }
105 |
106 | // [TestMethod]
107 | // public void CanMatchSingleColor_WithDecimalsAndF()
108 | // {
109 | // var sut = new Color32Tagger(new FakeTextBuffer());
110 |
111 | // Assert.IsNotNull(sut);
112 |
113 | // var lineWithColor = "var testValue = new Color32(0.0f, 1.0f, 1.0f, 1.0f)";
114 |
115 | // var matches = sut.ColorExpression.Matches(lineWithColor).Cast();
116 |
117 | // Assert.AreEqual(1, matches.Count());
118 |
119 | // var tag = sut.TryCreateTagForMatch(matches.First(), 0, 0, 0, lineWithColor);
120 |
121 | // Assert.IsNotNull(tag);
122 | // }
123 |
124 | // [TestMethod]
125 | // public void CanMatchSingleColor_WithDecimalsAndFButNoSpaces()
126 | // {
127 | // var sut = new Color32Tagger(new FakeTextBuffer());
128 |
129 | // Assert.IsNotNull(sut);
130 |
131 | // var lineWithColor = "var testValue = new Color32(0.0f,1.0f,1.0f,1.0f)";
132 |
133 | // var matches = sut.ColorExpression.Matches(lineWithColor).Cast();
134 |
135 | // Assert.AreEqual(1, matches.Count());
136 |
137 | // var tag = sut.TryCreateTagForMatch(matches.First(), 0, 0, 0, lineWithColor);
138 |
139 | // Assert.IsNotNull(tag);
140 | // }
141 |
142 | // [TestMethod]
143 | // public void DoesNotMatch_InconsequentialText()
144 | // {
145 | // base.DoesNotMatch_InconsequentialText();
146 | // }
147 | //}
148 |
149 |
--------------------------------------------------------------------------------
/src/CSInlineColorViz.Tests/ColorFromArgbTaggerTests.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Text.RegularExpressions;
3 | using CsInlineColorViz;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | namespace CSInlineColorViz.Tests;
7 |
8 | [TestClass]
9 | public class ColorFromArgbTaggerTests : BaseTaggerTests
10 | {
11 | [TestMethod]
12 | public void NoNameSpace()
13 | {
14 | var testLine = "var color = Color.FromArgb(255, 125, 125, 125); ";
15 |
16 | CreatesOneMatchAndTag(testLine);
17 | }
18 |
19 | [TestMethod]
20 | public void WithNameSpace_System_Drawing()
21 | {
22 | var testLine = "var color = System.Drawing.Color.FromArgb(255, 255, 125, 0); ";
23 |
24 | CreatesOneMatchAndTag(testLine);
25 | }
26 |
27 | [TestMethod]
28 | public void WithNameSpace_Windows_UI()
29 | {
30 | var testLine = "var color = Windows.UI.Color.FromArgb(255, 125, 125, 125); ";
31 |
32 | CreatesOneMatchAndTag(testLine);
33 | }
34 |
35 | private void CreatesOneMatchAndTag(string lineOfCode)
36 | {
37 | var sut = new ColorArgbTagger(new FakeTextBuffer());
38 |
39 | Assert.IsNotNull(sut, "Failed to create tagger");
40 |
41 | var matches = sut.ColorExpression.Matches(lineOfCode).Cast();
42 |
43 | Assert.AreEqual(1, matches.Count());
44 |
45 | var tag = sut.TryCreateTagForMatch(matches.First(), 0, 0, 0, lineOfCode);
46 |
47 | Assert.IsNotNull(tag, "Failed to create a tag from the match");
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/CSInlineColorViz.Tests/ColorListHelperTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using CsInlineColorViz;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | namespace CSInlineColorViz.Tests;
7 |
8 | [TestClass]
9 | public class ColorListHelperTests
10 | {
11 | [TestMethod]
12 | public void Ensure_ConsoleColor_AlphabeticalList_AsEnum()
13 | {
14 | var enumValues = Enum.GetValues(typeof(System.ConsoleColor)).Cast