├── .editorconfig
├── .gitattributes
├── .github
└── workflows
│ ├── codeql-analysis.yml
│ └── netcore.yml
├── .gitignore
├── .travis.yml
├── LICENSE
├── NuGet.Config
├── README.md
├── Scrutor.AspNetCore.sln
├── azure-pipelines.yml
├── global.json
└── src
└── Scrutor.AspNetCore
├── ApplicationBuilderExtensions.cs
├── DependencyContext.cs
├── IDependencyContext.cs
├── IScopedLifetime.cs
├── ISelfScopedLifetime.cs
├── ISelfSingletonLifetime.cs
├── ISelfTransientLifetime.cs
├── ISingletonLifetime.cs
├── ITransientLifetime.cs
├── Scrutor.AspNetCore.csproj
├── ServiceCollectionExtensions.cs
└── ServiceLocator.cs
/.editorconfig:
--------------------------------------------------------------------------------
1 | ; This is the default for the codeline.
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | charset = utf-8
7 | trim_trailing_whitespace = true
8 | insert_final_newline = true
9 |
10 | # C# files
11 | [*.cs]
12 |
13 | #### Core EditorConfig Options ####
14 |
15 | # Indentation and spacing
16 | indent_size = 4
17 | indent_style = space
18 | tab_width = 4
19 |
20 | # New line preferences
21 | end_of_line = crlf
22 | insert_final_newline = false
23 |
24 | #### .NET Coding Conventions ####
25 |
26 | # Organize usings
27 | dotnet_separate_import_directive_groups = false
28 | dotnet_sort_system_directives_first = false
29 |
30 | # this. and Me. preferences
31 | dotnet_style_qualification_for_event = false:silent
32 | dotnet_style_qualification_for_field = false:silent
33 | dotnet_style_qualification_for_method = false:silent
34 | dotnet_style_qualification_for_property = false:silent
35 |
36 | # Language keywords vs BCL types preferences
37 | dotnet_style_predefined_type_for_locals_parameters_members = true:silent
38 | dotnet_style_predefined_type_for_member_access = true:silent
39 |
40 | # Parentheses preferences
41 | dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
42 | dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
43 | dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
44 | dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
45 |
46 | # Modifier preferences
47 | dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
48 |
49 | # Expression-level preferences
50 | csharp_style_deconstructed_variable_declaration = true:suggestion
51 | csharp_style_inlined_variable_declaration = true:suggestion
52 | csharp_style_throw_expression = true:suggestion
53 | dotnet_style_coalesce_expression = true:suggestion
54 | dotnet_style_collection_initializer = true:none
55 | dotnet_style_explicit_tuple_names = true:suggestion
56 | dotnet_style_null_propagation = true:suggestion
57 | dotnet_style_object_initializer = true:suggestion
58 | dotnet_style_prefer_auto_properties = true:silent
59 | dotnet_style_prefer_compound_assignment = true:suggestion
60 | dotnet_style_prefer_conditional_expression_over_assignment = true:silent
61 | dotnet_style_prefer_conditional_expression_over_return = true:silent
62 | dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
63 | dotnet_style_prefer_inferred_tuple_names = true:suggestion
64 | dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
65 |
66 | # Field preferences
67 | dotnet_style_readonly_field = true:suggestion
68 |
69 | # Parameter preferences
70 | dotnet_code_quality_unused_parameters = all:suggestion
71 |
72 | #### C# Coding Conventions ####
73 |
74 | # var preferences
75 | csharp_style_var_elsewhere = false:silent
76 | csharp_style_var_for_built_in_types = false:silent
77 | csharp_style_var_when_type_is_apparent = false:silent
78 |
79 | # Expression-bodied members
80 | csharp_style_expression_bodied_accessors = true:silent
81 | csharp_style_expression_bodied_constructors = false:silent
82 | csharp_style_expression_bodied_indexers = true:silent
83 | csharp_style_expression_bodied_lambdas = true:silent
84 | csharp_style_expression_bodied_local_functions = false:silent
85 | csharp_style_expression_bodied_methods = false:silent
86 | csharp_style_expression_bodied_operators = false:silent
87 | csharp_style_expression_bodied_properties = true:silent
88 |
89 | # Pattern matching preferences
90 | csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
91 | csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
92 |
93 | # Null-checking preferences
94 | csharp_style_conditional_delegate_call = true:suggestion
95 |
96 | # Modifier preferences
97 | csharp_prefer_static_local_function = true:suggestion
98 | csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
99 |
100 | # Code-block preferences
101 | csharp_prefer_braces = true:silent
102 | csharp_prefer_simple_using_statement = true:none
103 |
104 | # Expression-level preferences
105 | csharp_prefer_simple_default_expression = true:suggestion
106 | csharp_style_pattern_local_over_anonymous_function = true:suggestion
107 | csharp_style_prefer_index_operator = true:suggestion
108 | csharp_style_prefer_range_operator = true:suggestion
109 | csharp_style_unused_value_assignment_preference = discard_variable:suggestion
110 | csharp_style_unused_value_expression_statement_preference = discard_variable:silent
111 |
112 | # 'using' directive preferences
113 | csharp_using_directive_placement = outside_namespace:silent
114 |
115 | #### C# Formatting Rules ####
116 |
117 | # New line preferences
118 | csharp_new_line_before_catch = true
119 | csharp_new_line_before_else = true
120 | csharp_new_line_before_finally = true
121 | csharp_new_line_before_members_in_anonymous_types = true
122 | csharp_new_line_before_members_in_object_initializers = true
123 | csharp_new_line_before_open_brace = all
124 | csharp_new_line_between_query_expression_clauses = true
125 |
126 | # Indentation preferences
127 | csharp_indent_block_contents = true
128 | csharp_indent_braces = false
129 | csharp_indent_case_contents = false
130 | csharp_indent_case_contents_when_block = false
131 | csharp_indent_labels = one_less_than_current
132 | csharp_indent_switch_labels = true
133 |
134 | # Space preferences
135 | csharp_space_after_cast = false
136 | csharp_space_after_colon_in_inheritance_clause = true
137 | csharp_space_after_comma = true
138 | csharp_space_after_dot = false
139 | csharp_space_after_keywords_in_control_flow_statements = true
140 | csharp_space_after_semicolon_in_for_statement = true
141 | csharp_space_around_binary_operators = before_and_after
142 | csharp_space_around_declaration_statements = false
143 | csharp_space_before_colon_in_inheritance_clause = true
144 | csharp_space_before_comma = false
145 | csharp_space_before_dot = false
146 | csharp_space_before_open_square_brackets = false
147 | csharp_space_before_semicolon_in_for_statement = false
148 | csharp_space_between_empty_square_brackets = false
149 | csharp_space_between_method_call_empty_parameter_list_parentheses = false
150 | csharp_space_between_method_call_name_and_opening_parenthesis = false
151 | csharp_space_between_method_call_parameter_list_parentheses = false
152 | csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
153 | csharp_space_between_method_declaration_name_and_open_parenthesis = false
154 | csharp_space_between_method_declaration_parameter_list_parentheses = false
155 | csharp_space_between_parentheses = false
156 | csharp_space_between_square_brackets = false
157 |
158 | # Wrapping preferences
159 | csharp_preserve_single_line_blocks = true
160 | csharp_preserve_single_line_statements = false
161 |
162 | #### Naming styles ####
163 |
164 | # Naming rules
165 |
166 | dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
167 | dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
168 | dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
169 |
170 | dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
171 | dotnet_naming_rule.types_should_be_pascal_case.symbols = types
172 | dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
173 |
174 | dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
175 | dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
176 | dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
177 |
178 | # Symbol specifications
179 |
180 | dotnet_naming_symbols.interface.applicable_kinds = interface
181 | dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal
182 | dotnet_naming_symbols.interface.required_modifiers =
183 |
184 | dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
185 | dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal
186 | dotnet_naming_symbols.types.required_modifiers =
187 |
188 | dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
189 | dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal
190 | dotnet_naming_symbols.non_field_members.required_modifiers =
191 |
192 | # Naming styles
193 |
194 | dotnet_naming_style.pascal_case.required_prefix =
195 | dotnet_naming_style.pascal_case.required_suffix =
196 | dotnet_naming_style.pascal_case.word_separator =
197 | dotnet_naming_style.pascal_case.capitalization = pascal_case
198 |
199 | dotnet_naming_style.begins_with_i.required_prefix = I
200 | dotnet_naming_style.begins_with_i.required_suffix =
201 | dotnet_naming_style.begins_with_i.word_separator =
202 | dotnet_naming_style.begins_with_i.capitalization = pascal_case
203 |
204 | [*.{xml,config,*proj,nuspec,props,resx,targets,yml,tasks}]
205 | indent_size = 2
206 |
207 | [*.json]
208 | indent_size = 2
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.github/workflows/codeql-analysis.yml:
--------------------------------------------------------------------------------
1 | name: CodeQL Analysis
2 |
3 | on: [push]
4 |
5 | jobs:
6 | analyze:
7 | name: CodeQL Analysis
8 | runs-on: ubuntu-latest
9 | env:
10 | SOLUTION_PATH: ./Scrutor.AspNetCore.sln
11 | steps:
12 | - name: Checkout repository
13 | id: checkout_repo
14 | uses: actions/checkout@v2
15 |
16 | - name: Initialize CodeQL
17 | id: init_codeql
18 | uses: github/codeql-action/init@v1
19 | with:
20 | queries: security-and-quality
21 |
22 | - name: Build application
23 | id: build_app
24 | shell: pwsh
25 | run: |
26 | dotnet build $env:SOLUTION_PATH
27 | - name: Perform CodeQL Analysis
28 | id: analyze_codeql
29 | uses: github/codeql-action/analyze@v1
30 |
--------------------------------------------------------------------------------
/.github/workflows/netcore.yml:
--------------------------------------------------------------------------------
1 | name: .NET Core CI
2 |
3 | on: [push]
4 |
5 | jobs:
6 | build_and_test:
7 | runs-on: ${{ matrix.os }}
8 | strategy:
9 | matrix:
10 | os: [ubuntu-latest]
11 | steps:
12 | - name: Setup .NET 5.0
13 | uses: actions/setup-dotnet@v1
14 | with:
15 | dotnet-version: 5.0.101
16 |
17 | - name: Setup .NET Core 3.1
18 | uses: actions/setup-dotnet@v1
19 | with:
20 | dotnet-version: 3.1.403
21 | if: matrix.os == 'ubuntu-latest'
22 | - uses: actions/checkout@v1
23 | - name: Build
24 | run: dotnet build ./Scrutor.AspNetCore.sln --configuration Release
25 | - name: Pack
26 | run: dotnet pack -c Release --no-build -o ./packages
27 | - name: Push
28 | run: dotnet nuget push ./packages/Scrutor.AspNetCore.*.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TOKEN}} --source https://api.nuget.org/v3/index.json
29 |
30 |
31 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/csharp,aspnetcore,visualstudio,visualstudiocode
3 | # Edit at https://www.gitignore.io/?templates=csharp,aspnetcore,visualstudio,visualstudiocode
4 |
5 | ### ASPNETCore ###
6 | ## Ignore Visual Studio temporary files, build results, and
7 | ## files generated by popular Visual Studio add-ons.
8 |
9 | # User-specific files
10 | *.suo
11 | *.user
12 | *.userosscache
13 | *.sln.docstates
14 |
15 | # User-specific files (MonoDevelop/Xamarin Studio)
16 | *.userprefs
17 |
18 | # Build results
19 | [Dd]ebug/
20 | [Dd]ebugPublic/
21 | [Rr]elease/
22 | [Rr]eleases/
23 | x64/
24 | x86/
25 | bld/
26 | [Bb]in/
27 | [Oo]bj/
28 | [Ll]og/
29 |
30 | # Visual Studio 2015 cache/options directory
31 | .vs/
32 | # Uncomment if you have tasks that create the project's static files in wwwroot
33 | #wwwroot/
34 |
35 | # MSTest test Results
36 | [Tt]est[Rr]esult*/
37 | [Bb]uild[Ll]og.*
38 |
39 | # NUNIT
40 | *.VisualState.xml
41 | TestResult.xml
42 |
43 | # Build Results of an ATL Project
44 | [Dd]ebugPS/
45 | [Rr]eleasePS/
46 | dlldata.c
47 |
48 | # DNX
49 | project.lock.json
50 | project.fragment.lock.json
51 | artifacts/
52 |
53 | *_i.c
54 | *_p.c
55 | *_i.h
56 | *.ilk
57 | *.meta
58 | *.obj
59 | *.pch
60 | *.pdb
61 | *.pgc
62 | *.pgd
63 | *.rsp
64 | *.sbr
65 | *.tlb
66 | *.tli
67 | *.tlh
68 | *.tmp
69 | *.tmp_proj
70 | *.log
71 | *.vspscc
72 | *.vssscc
73 | .builds
74 | *.pidb
75 | *.svclog
76 | *.scc
77 |
78 | # Chutzpah Test files
79 | _Chutzpah*
80 |
81 | # Visual C++ cache files
82 | ipch/
83 | *.aps
84 | *.ncb
85 | *.opendb
86 | *.opensdf
87 | *.sdf
88 | *.cachefile
89 | *.VC.db
90 | *.VC.VC.opendb
91 |
92 | # Visual Studio profiler
93 | *.psess
94 | *.vsp
95 | *.vspx
96 | *.sap
97 |
98 | # TFS 2012 Local Workspace
99 | $tf/
100 |
101 | # Guidance Automation Toolkit
102 | *.gpState
103 |
104 | # ReSharper is a .NET coding add-in
105 | _ReSharper*/
106 | *.[Rr]e[Ss]harper
107 | *.DotSettings.user
108 |
109 | # JustCode is a .NET coding add-in
110 | .JustCode
111 |
112 | # TeamCity is a build add-in
113 | _TeamCity*
114 |
115 | # DotCover is a Code Coverage Tool
116 | *.dotCover
117 |
118 | # Visual Studio code coverage results
119 | *.coverage
120 | *.coveragexml
121 |
122 | # NCrunch
123 | _NCrunch_*
124 | .*crunch*.local.xml
125 | nCrunchTemp_*
126 |
127 | # MightyMoose
128 | *.mm.*
129 | AutoTest.Net/
130 |
131 | # Web workbench (sass)
132 | .sass-cache/
133 |
134 | # Installshield output folder
135 | [Ee]xpress/
136 |
137 | # DocProject is a documentation generator add-in
138 | DocProject/buildhelp/
139 | DocProject/Help/*.HxT
140 | DocProject/Help/*.HxC
141 | DocProject/Help/*.hhc
142 | DocProject/Help/*.hhk
143 | DocProject/Help/*.hhp
144 | DocProject/Help/Html2
145 | DocProject/Help/html
146 |
147 | # Click-Once directory
148 | publish/
149 |
150 | # Publish Web Output
151 | *.[Pp]ublish.xml
152 | *.azurePubxml
153 | # TODO: Comment the next line if you want to checkin your web deploy settings
154 | # but database connection strings (with potential passwords) will be unencrypted
155 | *.pubxml
156 | *.publishproj
157 |
158 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
159 | # checkin your Azure Web App publish settings, but sensitive information contained
160 | # in these scripts will be unencrypted
161 | PublishScripts/
162 |
163 | # NuGet Packages
164 | *.nupkg
165 | # The packages folder can be ignored because of Package Restore
166 | **/packages/*
167 | # except build/, which is used as an MSBuild target.
168 | !**/packages/build/
169 | # Uncomment if necessary however generally it will be regenerated when needed
170 | #!**/packages/repositories.config
171 | # NuGet v3's project.json files produces more ignoreable files
172 | *.nuget.props
173 | *.nuget.targets
174 |
175 | # Microsoft Azure Build Output
176 | csx/
177 | *.build.csdef
178 |
179 | # Microsoft Azure Emulator
180 | ecf/
181 | rcf/
182 |
183 | # Windows Store app package directories and files
184 | AppPackages/
185 | BundleArtifacts/
186 | Package.StoreAssociation.xml
187 | _pkginfo.txt
188 |
189 | # Visual Studio cache files
190 | # files ending in .cache can be ignored
191 | *.[Cc]ache
192 | # but keep track of directories ending in .cache
193 | !*.[Cc]ache/
194 |
195 | # Others
196 | ClientBin/
197 | ~$*
198 | *~
199 | *.dbmdl
200 | *.dbproj.schemaview
201 | *.jfm
202 | *.pfx
203 | *.publishsettings
204 | node_modules/
205 | orleans.codegen.cs
206 |
207 | # Since there are multiple workflows, uncomment next line to ignore bower_components
208 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
209 | #bower_components/
210 |
211 | # RIA/Silverlight projects
212 | Generated_Code/
213 |
214 | # Backup & report files from converting an old project file
215 | # to a newer Visual Studio version. Backup files are not needed,
216 | # because we have git ;-)
217 | _UpgradeReport_Files/
218 | Backup*/
219 | UpgradeLog*.XML
220 | UpgradeLog*.htm
221 |
222 | # SQL Server files
223 | *.mdf
224 | *.ldf
225 |
226 | # Business Intelligence projects
227 | *.rdl.data
228 | *.bim.layout
229 | *.bim_*.settings
230 |
231 | # Microsoft Fakes
232 | FakesAssemblies/
233 |
234 | # GhostDoc plugin setting file
235 | *.GhostDoc.xml
236 |
237 | # Node.js Tools for Visual Studio
238 | .ntvs_analysis.dat
239 |
240 | # Visual Studio 6 build log
241 | *.plg
242 |
243 | # Visual Studio 6 workspace options file
244 | *.opt
245 |
246 | # Visual Studio LightSwitch build output
247 | **/*.HTMLClient/GeneratedArtifacts
248 | **/*.DesktopClient/GeneratedArtifacts
249 | **/*.DesktopClient/ModelManifest.xml
250 | **/*.Server/GeneratedArtifacts
251 | **/*.Server/ModelManifest.xml
252 | _Pvt_Extensions
253 |
254 | # Paket dependency manager
255 | .paket/paket.exe
256 | paket-files/
257 |
258 | # FAKE - F# Make
259 | .fake/
260 |
261 | # JetBrains Rider
262 | .idea/
263 | *.sln.iml
264 |
265 | # CodeRush
266 | .cr/
267 |
268 | # Python Tools for Visual Studio (PTVS)
269 | __pycache__/
270 | *.pyc
271 |
272 | # Cake - Uncomment if you are using it
273 | # tools/
274 |
275 | ### Csharp ###
276 | ##
277 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
278 |
279 | # User-specific files
280 | *.rsuser
281 |
282 | # User-specific files (MonoDevelop/Xamarin Studio)
283 |
284 | # Mono auto generated files
285 | mono_crash.*
286 |
287 | # Build results
288 | [Aa][Rr][Mm]/
289 | [Aa][Rr][Mm]64/
290 |
291 | # Visual Studio 2015/2017 cache/options directory
292 | # Uncomment if you have tasks that create the project's static files in wwwroot
293 |
294 | # Visual Studio 2017 auto generated files
295 | Generated\ Files/
296 |
297 | # MSTest test Results
298 |
299 | # NUNIT
300 |
301 | # Build Results of an ATL Project
302 |
303 | # Benchmark Results
304 | BenchmarkDotNet.Artifacts/
305 |
306 | # .NET Core
307 |
308 | # StyleCop
309 | StyleCopReport.xml
310 |
311 | # Files built by Visual Studio
312 | *_h.h
313 | *.iobj
314 | *.ipdb
315 | *_wpftmp.csproj
316 |
317 | # Chutzpah Test files
318 |
319 | # Visual C++ cache files
320 |
321 | # Visual Studio profiler
322 |
323 | # Visual Studio Trace Files
324 | *.e2e
325 |
326 | # TFS 2012 Local Workspace
327 |
328 | # Guidance Automation Toolkit
329 |
330 | # ReSharper is a .NET coding add-in
331 |
332 | # JustCode is a .NET coding add-in
333 |
334 | # TeamCity is a build add-in
335 |
336 | # DotCover is a Code Coverage Tool
337 |
338 | # AxoCover is a Code Coverage Tool
339 | .axoCover/*
340 | !.axoCover/settings.json
341 |
342 | # Visual Studio code coverage results
343 |
344 | # NCrunch
345 |
346 | # MightyMoose
347 |
348 | # Web workbench (sass)
349 |
350 | # Installshield output folder
351 |
352 | # DocProject is a documentation generator add-in
353 |
354 | # Click-Once directory
355 |
356 | # Publish Web Output
357 | # Note: Comment the next line if you want to checkin your web deploy settings,
358 | # but database connection strings (with potential passwords) will be unencrypted
359 |
360 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
361 | # checkin your Azure Web App publish settings, but sensitive information contained
362 | # in these scripts will be unencrypted
363 |
364 | # NuGet Packages
365 | # The packages folder can be ignored because of Package Restore
366 | **/[Pp]ackages/*
367 | # except build/, which is used as an MSBuild target.
368 | !**/[Pp]ackages/build/
369 | # Uncomment if necessary however generally it will be regenerated when needed
370 | #!**/[Pp]ackages/repositories.config
371 | # NuGet v3's project.json files produces more ignorable files
372 |
373 | # Microsoft Azure Build Output
374 |
375 | # Microsoft Azure Emulator
376 |
377 | # Windows Store app package directories and files
378 | *.appx
379 | *.appxbundle
380 | *.appxupload
381 |
382 | # Visual Studio cache files
383 | # files ending in .cache can be ignored
384 | # but keep track of directories ending in .cache
385 | !?*.[Cc]ache/
386 |
387 | # Others
388 |
389 | # Including strong name files can present a security risk
390 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
391 | #*.snk
392 |
393 | # Since there are multiple workflows, uncomment next line to ignore bower_components
394 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
395 |
396 | # RIA/Silverlight projects
397 |
398 | # Backup & report files from converting an old project file
399 | # to a newer Visual Studio version. Backup files are not needed,
400 | # because we have git ;-)
401 | ServiceFabricBackup/
402 | *.rptproj.bak
403 |
404 | # SQL Server files
405 | *.ndf
406 |
407 | # Business Intelligence projects
408 | *.rptproj.rsuser
409 | *- Backup*.rdl
410 |
411 | # Microsoft Fakes
412 |
413 | # GhostDoc plugin setting file
414 |
415 | # Node.js Tools for Visual Studio
416 |
417 | # Visual Studio 6 build log
418 |
419 | # Visual Studio 6 workspace options file
420 |
421 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
422 | *.vbw
423 |
424 | # Visual Studio LightSwitch build output
425 |
426 | # Paket dependency manager
427 |
428 | # FAKE - F# Make
429 |
430 | # CodeRush personal settings
431 | .cr/personal
432 |
433 | # Python Tools for Visual Studio (PTVS)
434 |
435 | # Cake - Uncomment if you are using it
436 | # tools/**
437 | # !tools/packages.config
438 |
439 | # Tabs Studio
440 | *.tss
441 |
442 | # Telerik's JustMock configuration file
443 | *.jmconfig
444 |
445 | # BizTalk build output
446 | *.btp.cs
447 | *.btm.cs
448 | *.odx.cs
449 | *.xsd.cs
450 |
451 | # OpenCover UI analysis results
452 | OpenCover/
453 |
454 | # Azure Stream Analytics local run output
455 | ASALocalRun/
456 |
457 | # MSBuild Binary and Structured Log
458 | *.binlog
459 |
460 | # NVidia Nsight GPU debugger configuration file
461 | *.nvuser
462 |
463 | # MFractors (Xamarin productivity tool) working folder
464 | .mfractor/
465 |
466 | # Local History for Visual Studio
467 | .localhistory/
468 |
469 | # BeatPulse healthcheck temp database
470 | healthchecksdb
471 |
472 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
473 | MigrationBackup/
474 |
475 | ### VisualStudioCode ###
476 | .vscode/*
477 | !.vscode/settings.json
478 | !.vscode/tasks.json
479 | !.vscode/launch.json
480 | !.vscode/extensions.json
481 |
482 | ### VisualStudioCode Patch ###
483 | # Ignore all local history of files
484 | .history
485 |
486 | ### VisualStudio ###
487 |
488 | # User-specific files
489 |
490 | # User-specific files (MonoDevelop/Xamarin Studio)
491 |
492 | # Mono auto generated files
493 |
494 | # Build results
495 |
496 | # Visual Studio 2015/2017 cache/options directory
497 | # Uncomment if you have tasks that create the project's static files in wwwroot
498 |
499 | # Visual Studio 2017 auto generated files
500 |
501 | # MSTest test Results
502 |
503 | # NUNIT
504 |
505 | # Build Results of an ATL Project
506 |
507 | # Benchmark Results
508 |
509 | # .NET Core
510 |
511 | # StyleCop
512 |
513 | # Files built by Visual Studio
514 |
515 | # Chutzpah Test files
516 |
517 | # Visual C++ cache files
518 |
519 | # Visual Studio profiler
520 |
521 | # Visual Studio Trace Files
522 |
523 | # TFS 2012 Local Workspace
524 |
525 | # Guidance Automation Toolkit
526 |
527 | # ReSharper is a .NET coding add-in
528 |
529 | # JustCode is a .NET coding add-in
530 |
531 | # TeamCity is a build add-in
532 |
533 | # DotCover is a Code Coverage Tool
534 |
535 | # AxoCover is a Code Coverage Tool
536 |
537 | # Visual Studio code coverage results
538 |
539 | # NCrunch
540 |
541 | # MightyMoose
542 |
543 | # Web workbench (sass)
544 |
545 | # Installshield output folder
546 |
547 | # DocProject is a documentation generator add-in
548 |
549 | # Click-Once directory
550 |
551 | # Publish Web Output
552 | # Note: Comment the next line if you want to checkin your web deploy settings,
553 | # but database connection strings (with potential passwords) will be unencrypted
554 |
555 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
556 | # checkin your Azure Web App publish settings, but sensitive information contained
557 | # in these scripts will be unencrypted
558 |
559 | # NuGet Packages
560 | # The packages folder can be ignored because of Package Restore
561 | # except build/, which is used as an MSBuild target.
562 | # Uncomment if necessary however generally it will be regenerated when needed
563 | # NuGet v3's project.json files produces more ignorable files
564 |
565 | # Microsoft Azure Build Output
566 |
567 | # Microsoft Azure Emulator
568 |
569 | # Windows Store app package directories and files
570 |
571 | # Visual Studio cache files
572 | # files ending in .cache can be ignored
573 | # but keep track of directories ending in .cache
574 |
575 | # Others
576 |
577 | # Including strong name files can present a security risk
578 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
579 |
580 | # Since there are multiple workflows, uncomment next line to ignore bower_components
581 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
582 |
583 | # RIA/Silverlight projects
584 |
585 | # Backup & report files from converting an old project file
586 | # to a newer Visual Studio version. Backup files are not needed,
587 | # because we have git ;-)
588 |
589 | # SQL Server files
590 |
591 | # Business Intelligence projects
592 |
593 | # Microsoft Fakes
594 |
595 | # GhostDoc plugin setting file
596 |
597 | # Node.js Tools for Visual Studio
598 |
599 | # Visual Studio 6 build log
600 |
601 | # Visual Studio 6 workspace options file
602 |
603 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
604 |
605 | # Visual Studio LightSwitch build output
606 |
607 | # Paket dependency manager
608 |
609 | # FAKE - F# Make
610 |
611 | # CodeRush personal settings
612 |
613 | # Python Tools for Visual Studio (PTVS)
614 |
615 | # Cake - Uncomment if you are using it
616 | # tools/**
617 | # !tools/packages.config
618 |
619 | # Tabs Studio
620 |
621 | # Telerik's JustMock configuration file
622 |
623 | # BizTalk build output
624 |
625 | # OpenCover UI analysis results
626 |
627 | # Azure Stream Analytics local run output
628 |
629 | # MSBuild Binary and Structured Log
630 |
631 | # NVidia Nsight GPU debugger configuration file
632 |
633 | # MFractors (Xamarin productivity tool) working folder
634 |
635 | # Local History for Visual Studio
636 |
637 | # BeatPulse healthcheck temp database
638 |
639 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
640 |
641 | # End of https://www.gitignore.io/api/csharp,aspnetcore,visualstudio,visualstudiocode
642 |
643 | [Bb]undles/
644 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: csharp
2 | mono: none
3 | dotnet: 5.0.100
4 |
5 | dist: xenial
6 | os: linux
7 |
8 | script:
9 | - dotnet build ./Scrutor.AspNetCore.sln --configuration Release
10 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2020 Sefa Can
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 |
--------------------------------------------------------------------------------
/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Scrutor.AspNetCore
2 |
3 | ASP.NET Core [Scrutor](https://github.com/khellang/Scrutor) extension for automatic registration of classes inherited from IScopedLifetime, ISelfScopedLifetime, ITransientLifetime, ISelfTransientLifetime, ISingletonLifetime, ISelfSingletonLifetime
4 |
5 | ### Build Status
6 | | Build server | Platform | Status |
7 | |-----------------|----------------|-------------|
8 | | Azure CI Pipelines | All | |
9 | | Github Actions | All | |
10 | | Travis CI | Linux | |
11 |
12 | ## Installation
13 |
14 | Install the [Scrutor.AspNetCore NuGet Package](https://www.nuget.org/packages/Scrutor.AspNetCore).
15 |
16 | ### Package Manager Console
17 |
18 | ```
19 | Install-Package Scrutor.AspNetCore
20 | ```
21 |
22 | ### .NET Core CLI
23 |
24 | ```
25 | dotnet add package Scrutor.AspNetCore
26 | ```
27 |
28 | ## Usage
29 |
30 | ```csharp
31 | public void ConfigureServices(IServiceCollection services)
32 | {
33 | //add to the end of the method
34 | services.AddAdvancedDependencyInjection();
35 | }
36 |
37 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
38 | {
39 | //add to the end of the method
40 | app.UseAdvancedDependencyInjection();
41 | }
42 |
43 | //usage without constructor classes
44 | var service = ServiceLocator.Context.GetService();
45 | ```
46 |
--------------------------------------------------------------------------------
/Scrutor.AspNetCore.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29806.167
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Scrutor.AspNetCore", "src\Scrutor.AspNetCore\Scrutor.AspNetCore.csproj", "{74722B5F-5FF2-4A5B-A67D-508E97AF67D7}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E30E4B2A-7C8B-430A-94A7-4ABBE1EF89B9}"
9 | ProjectSection(SolutionItems) = preProject
10 | .editorconfig = .editorconfig
11 | .gitattributes = .gitattributes
12 | .gitignore = .gitignore
13 | .travis.yml = .travis.yml
14 | global.json = global.json
15 | LICENSE = LICENSE
16 | NuGet.Config = NuGet.Config
17 | README.md = README.md
18 | EndProjectSection
19 | EndProject
20 | Global
21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
22 | Debug|Any CPU = Debug|Any CPU
23 | Release|Any CPU = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
26 | {74722B5F-5FF2-4A5B-A67D-508E97AF67D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {74722B5F-5FF2-4A5B-A67D-508E97AF67D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {74722B5F-5FF2-4A5B-A67D-508E97AF67D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {74722B5F-5FF2-4A5B-A67D-508E97AF67D7}.Release|Any CPU.Build.0 = Release|Any CPU
30 | EndGlobalSection
31 | GlobalSection(SolutionProperties) = preSolution
32 | HideSolutionNode = FALSE
33 | EndGlobalSection
34 | GlobalSection(ExtensibilityGlobals) = postSolution
35 | SolutionGuid = {E0F166DA-98C9-4465-B497-C3B74A5DB137}
36 | EndGlobalSection
37 | EndGlobal
38 |
--------------------------------------------------------------------------------
/azure-pipelines.yml:
--------------------------------------------------------------------------------
1 | # ASP.NET Core
2 | # Build and test ASP.NET Core projects targeting .NET Core.
3 | # Add steps that run tests, create a NuGet package, deploy, and more:
4 | # https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
5 |
6 | trigger:
7 | - master
8 |
9 | variables:
10 | netCoreSdkVersion: '3.1.101'
11 |
12 | jobs:
13 | - job: Linux
14 | pool:
15 | vmImage: 'Ubuntu 16.04'
16 | steps:
17 | - task: DotNetCoreInstaller@0
18 | inputs:
19 | packageType: 'sdk'
20 | version: $(netCoreSdkVersion)
21 | - script: dotnet build ./Scrutor.AspNetCore.sln
22 | displayName: 'dotnet build'
23 | - script: dotnet test ./Scrutor.AspNetCore.sln
24 | displayName: 'run tests'
25 | - task: PublishTestResults@2
26 | displayName: 'Publish Test Results **/*.trx'
27 | condition: succeededOrFailed()
28 | inputs:
29 | testResultsFormat: VSTest
30 | testResultsFiles: '**/*.trx'
31 |
32 | - job: macOS
33 | pool:
34 | vmImage: 'macOS-10.13'
35 | steps:
36 | - task: DotNetCoreInstaller@0
37 | inputs:
38 | packageType: 'sdk'
39 | version: $(netCoreSdkVersion)
40 | - script: dotnet build ./Scrutor.AspNetCore.sln
41 | displayName: 'dotnet build'
42 | - script: dotnet test ./Scrutor.AspNetCore.sln
43 | displayName: 'run tests'
44 | - task: PublishTestResults@2
45 | displayName: 'Publish Test Results **/*.trx'
46 | condition: succeededOrFailed()
47 | inputs:
48 | testResultsFormat: VSTest
49 | testResultsFiles: '**/*.trx'
50 |
51 | - job: Windows
52 | pool:
53 | vmImage: 'windows-2019'
54 | steps:
55 | - task: DotNetCoreInstaller@0
56 | inputs:
57 | packageType: 'sdk'
58 | version: $(netCoreSdkVersion)
59 | - script: dotnet build ./Scrutor.AspNetCore.sln
60 | displayName: 'dotnet build'
61 | - script: dotnet test ./Scrutor.AspNetCore.sln
62 | displayName: 'run tests'
63 | - task: PublishTestResults@2
64 | displayName: 'Publish Test Results **/*.trx'
65 | condition: succeededOrFailed()
66 | inputs:
67 | testResultsFormat: VSTest
68 | testResultsFiles: '**/*.trx'
69 |
--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "5.0.100",
4 | "rollForward": "latestFeature"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/src/Scrutor.AspNetCore/ApplicationBuilderExtensions.cs:
--------------------------------------------------------------------------------
1 | using Scrutor.AspNetCore;
2 | using Microsoft.Extensions.DependencyInjection;
3 |
4 | namespace Microsoft.AspNetCore.Builder
5 | {
6 | public static class ApplicationBuilderExtensions
7 | {
8 | public static IApplicationBuilder UseAdvancedDependencyInjection(this IApplicationBuilder app)
9 | {
10 | var dependencyContext = app.ApplicationServices.GetService();
11 | ServiceLocator.Initialize(dependencyContext);
12 |
13 | return app;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/Scrutor.AspNetCore/DependencyContext.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.DependencyInjection;
2 | using System;
3 | using System.Collections.Generic;
4 |
5 | namespace Scrutor.AspNetCore
6 | {
7 | public class DependencyContext : IDependencyContext
8 | {
9 | public IServiceProvider ServiceProvider { get; private set; }
10 |
11 | public DependencyContext(IServiceProvider serviceProvider)
12 | {
13 | ServiceProvider = serviceProvider;
14 | }
15 |
16 | public T GetService()
17 | {
18 | return ServiceProvider.GetService();
19 | }
20 |
21 | public IEnumerable GetServices()
22 | {
23 | return ServiceProvider.GetServices();
24 | }
25 |
26 | public object GetService(Type type)
27 | {
28 | return ServiceProvider.GetService(type);
29 | }
30 |
31 | public IEnumerable