├── .gitattributes ├── .github └── FUNDING.yml ├── .gitignore ├── LICENSE ├── ObservableConcurrentQueue.dll ├── Readme.md ├── WpfInPowerShell ├── Toolkit │ ├── Class1.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Toolkit.csproj │ └── packages.config ├── WpfInPowerShell.sln └── WpfInPowerShell │ ├── App.config │ ├── App.xaml │ ├── App.xaml.cs │ ├── BindingDecoratorBase.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings │ └── WpfInPowerShell.csproj ├── WpfToolkit.ps1 ├── demo ├── BackgroundTask │ ├── viewModels.ps1 │ └── window_withbgtask.ps1 ├── EventGuard │ ├── viewModels.ps1 │ └── window_withguard.ps1 ├── ModelViewController │ ├── MVC.ps1 │ └── MVVM.ps1 ├── NoClasses │ ├── no-classes.ps1 │ └── weird.ps1 ├── PokeBrowser.Csharp │ ├── PokeBrowser.sln │ ├── PokeBrowser.sln.DotSettings │ └── PokeBrowser │ │ ├── App.config │ │ ├── App.xaml │ │ ├── App.xaml.cs │ │ ├── MainViewModel.cs │ │ ├── MainWindow.xaml │ │ ├── MainWindow.xaml.cs │ │ ├── PokeBrowser.csproj │ │ ├── PokemonJson.cs │ │ ├── PokemonLinkViewModel.cs │ │ ├── PokemonViewModel.cs │ │ ├── Properties │ │ ├── AspChildControlTypeAttribute.cs │ │ ├── AspDataFieldAttribute.cs │ │ ├── AspDataFieldsAttribute.cs │ │ ├── AspMethodPropertyAttribute.cs │ │ ├── AspMvcActionAttribute.cs │ │ ├── AspMvcActionSelectorAttribute.cs │ │ ├── AspMvcAreaAttribute.cs │ │ ├── AspMvcAreaMasterLocationFormatAttribute.cs │ │ ├── AspMvcAreaPartialViewLocationFormatAttribute.cs │ │ ├── AspMvcAreaViewLocationFormatAttribute.cs │ │ ├── AspMvcControllerAttribute.cs │ │ ├── AspMvcDisplayTemplateAttribute.cs │ │ ├── AspMvcEditorTemplateAttribute.cs │ │ ├── AspMvcMasterAttribute.cs │ │ ├── AspMvcMasterLocationFormatAttribute.cs │ │ ├── AspMvcModelTypeAttribute.cs │ │ ├── AspMvcPartialViewAttribute.cs │ │ ├── AspMvcPartialViewLocationFormatAttribute.cs │ │ ├── AspMvcSuppressViewErrorAttribute.cs │ │ ├── AspMvcTemplateAttribute.cs │ │ ├── AspMvcViewAttribute.cs │ │ ├── AspMvcViewComponentAttribute.cs │ │ ├── AspMvcViewComponentViewAttribute.cs │ │ ├── AspMvcViewLocationFormatAttribute.cs │ │ ├── AspRequiredAttributeAttribute.cs │ │ ├── AspTypePropertyAttribute.cs │ │ ├── AssemblyInfo.cs │ │ ├── AssertionConditionAttribute.cs │ │ ├── AssertionConditionType.cs │ │ ├── AssertionMethodAttribute.cs │ │ ├── BaseTypeRequiredAttribute.cs │ │ ├── CanBeNullAttribute.cs │ │ ├── CannotApplyEqualityOperatorAttribute.cs │ │ ├── CollectionAccessAttribute.cs │ │ ├── CollectionAccessType.cs │ │ ├── ContractAnnotationAttribute.cs │ │ ├── HtmlAttributeValueAttribute.cs │ │ ├── HtmlElementAttributesAttribute.cs │ │ ├── ImplicitUseKindFlags.cs │ │ ├── ImplicitUseTargetFlags.cs │ │ ├── InstantHandleAttribute.cs │ │ ├── InvokerParameterNameAttribute.cs │ │ ├── ItemCanBeNullAttribute.cs │ │ ├── ItemNotNullAttribute.cs │ │ ├── LinqTunnelAttribute.cs │ │ ├── LocalizationRequiredAttribute.cs │ │ ├── MacroAttribute.cs │ │ ├── MeansImplicitUseAttribute.cs │ │ ├── MustUseReturnValueAttribute.cs │ │ ├── NoEnumerationAttribute.cs │ │ ├── NoReorderAttribute.cs │ │ ├── NotNullAttribute.cs │ │ ├── NotifyPropertyChangedInvocatorAttribute.cs │ │ ├── PathReferenceAttribute.cs │ │ ├── ProvidesContextAttribute.cs │ │ ├── PublicAPIAttribute.cs │ │ ├── PureAttribute.cs │ │ ├── RazorDirectiveAttribute.cs │ │ ├── RazorHelperCommonAttribute.cs │ │ ├── RazorImportNamespaceAttribute.cs │ │ ├── RazorInjectionAttribute.cs │ │ ├── RazorLayoutAttribute.cs │ │ ├── RazorPageBaseTypeAttribute.cs │ │ ├── RazorSectionAttribute.cs │ │ ├── RazorWriteLiteralMethodAttribute.cs │ │ ├── RazorWriteMethodAttribute.cs │ │ ├── RazorWriteMethodParameterAttribute.cs │ │ ├── RegexPatternAttribute.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ ├── Settings.settings │ │ ├── SourceTemplateAttribute.cs │ │ ├── StringFormatMethodAttribute.cs │ │ ├── TerminatesProgramAttribute.cs │ │ ├── UsedImplicitlyAttribute.cs │ │ ├── ValueProviderAttribute.cs │ │ ├── XamlItemBindingOfItemsControlAttribute.cs │ │ └── XamlItemsControlAttribute.cs │ │ ├── RelayCommand.cs │ │ ├── ViewModelBase.cs │ │ └── packages.config └── PokeBrowser.Ps │ ├── MainView.ps1 │ ├── MainViewModel.ps1 │ ├── PokeBrowser.ps1 │ ├── PokemonLinkViewModel.ps1 │ ├── PokemonViewModel.ps1 │ └── Tasks.ps1 ├── doc ├── View.PNG ├── ViewModel.PNG └── mvvmpowershell.gif ├── eventcallbacks.ps1 ├── log.txt ├── outsideconfigforBackgroundWorkScript.ps1 ├── q.ps1 ├── refreshingBrowserViewModel.ps1 └── wpf.ps1 /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [nohwnd] 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Jakub Jareš 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 | -------------------------------------------------------------------------------- /ObservableConcurrentQueue.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nohwnd/WpfToolkit/fa2afa1326ebfc376134a31b934df017c231c4a0/ObservableConcurrentQueue.dll -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | ## Problem 2 | 3 | WPF is super awkward in PowerShell, it would be nice to be able to use powershell classes to work with it. 4 | 5 | - Use commands to run code on Model (Command -> Model) - ✔ Done 6 | - Notify UI when property is set. (Model -> UI) - ✔ Done 7 | - Do lightweight work in the command. - ✔ Done 8 | - Do work on background on command. - ✔ Done 9 | 10 | ## Todo: 11 | 12 | - multiple background tasks at the same time (seemed to work fine) 13 | - moving additional data from the foreground to the background (a hashtable to splat over $work?) 14 | - moving additional data from the background back to the foreground (collect output from $work and add $output to the callback) 15 | 16 | - leveraging CanExecute 17 | - command parameters 18 | 19 | - Notify model when property is set. ( UI -> Model) -> probably via custom binding that notifies automatically - is it even needed? 20 | - pattern for cooperative cancellation 21 | - simple stuff should still stay simple! 22 | - not too many conventions! 23 | 24 | ## Demo 25 | 26 | In the demo I have a view written in XAML and a viewModel written as a PowerShell class inheriting from my helper base class. 27 | 28 | I am pressing the button that adds `*` to the text to show that the UI is responsive while a long running task is processed in the background. The task in background repeatedly sleeps for 2 seconds and updates the progress via dispatcher. At the end it executes a bigger script via dispatcher to make updating the ViewModel after the task is easier. 29 | 30 | ![Demo](doc/mvvmpowershell.gif?raw=true) 31 | 32 | ```powershell 33 | # this is the view model, view model is a programmatical 34 | # representation of the view, when we manipulated the viewodel 35 | # the view should update automatically to present it 36 | class MainViewModel : WpfToolkit.ViewModelBase { 37 | # those are properties of the view model 38 | # those properties hold data that we show in the 39 | # view 40 | [String] $Text = "*" 41 | [int] $Progress 42 | 43 | # those are commands, those commands 44 | # can be triggered by the view to do some action 45 | [Windows.Input.ICommand] $RunBackgroundTask 46 | [Windows.Input.ICommand] $AddStar 47 | 48 | 49 | MainViewModel () { 50 | # Init makes up for lack of getters and 51 | # setters on properties by adding 52 | # Get* and Set* methods on the view model 53 | # eg .SetProgress() 54 | $this.Init('Text') 55 | $this.Init('Progress') 56 | 57 | # this scriptblock represents work to be 58 | # done on background, the work runs in a different 59 | # runspace, but we make it look very "local" 60 | # the runspace defines Dispatch function that can 61 | # be used to Invoke on the default Dispatcher 62 | $work = { 63 | param($this, $o) 64 | 65 | Dispatch { $this.SetProgress(10) } 66 | # running this on the main thread would 67 | # make the UI unresponsive 68 | Start-Sleep -Seconds 2 69 | 70 | Dispatch { $this.SetProgress(50) } 71 | 72 | Start-Sleep -Seconds 2 73 | Dispatch { $this.SetProgress(90) } 74 | } 75 | 76 | # this whole script will be invoked 77 | # via dispatcher after $work is done 78 | $callback = { 79 | param($this) 80 | 81 | 82 | $this.SetText($this.Text + " Background task done. ") 83 | $this.SetProgress(100) 84 | } 85 | 86 | # setting up the commands via helper 87 | # methods on the base view model. 88 | $this.RunBackgroundTask = $this.NewBackgroundCommand($work, $callback) 89 | $this.AddStar = $this.NewCommand({ $this.SetText($this.Text + "*") }) 90 | } 91 | } 92 | 93 | # this is the view written in XAML, notice that there are no 94 | # explicit names anywhere, instead of looking up components in the 95 | # underlying code and populating them on update, we are using the 96 | # binding capabilities that are native to WPF. The binding automatically 97 | # synchronizes our ViewModel to the View (and vice versa if we change) 98 | # data in the view (eg. we write something into the text box). 99 | 100 | # we also bind the Buttons to commands, instead of looking up the 101 | # the button by name and adding click event handlers. 102 | [string]$xaml = @" 103 | 106 | 107 | 109 | 111 | 112 | 14 | Select Pokemon: 15 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | Weight 26 | 27 | 28 | Height 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 52 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace PokeBrowser 4 | { 5 | /// 6 | /// Interaction logic for MainWindow.xaml 7 | /// 8 | public partial class MainWindow : Window 9 | { 10 | public MainWindow() 11 | { 12 | InitializeComponent(); 13 | DataContext = new MainViewModel(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/PokeBrowser.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {75CC5F74-535F-4C09-B7F1-04B1FBB3447D} 8 | WinExe 9 | PokeBrowser 10 | PokeBrowser 11 | v4.6.1 12 | 512 13 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | 4 15 | true 16 | true 17 | 18 | 19 | AnyCPU 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | AnyCPU 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | ..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll 40 | 41 | 42 | 43 | 44 | ..\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 4.0 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | MSBuild:Compile 62 | Designer 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | MSBuild:Compile 142 | Designer 143 | 144 | 145 | App.xaml 146 | Code 147 | 148 | 149 | 150 | MainWindow.xaml 151 | Code 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | Code 160 | 161 | 162 | True 163 | True 164 | Resources.resx 165 | 166 | 167 | True 168 | Settings.settings 169 | True 170 | 171 | 172 | ResXFileCodeGenerator 173 | Resources.Designer.cs 174 | 175 | 176 | 177 | SettingsSingleFileGenerator 178 | Settings.Designer.cs 179 | 180 | 181 | 182 | 183 | 184 | 185 | -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/PokemonJson.cs: -------------------------------------------------------------------------------- 1 | namespace PokeBrowser 2 | { 3 | class PokemonJson 4 | 5 | { 6 | public PokemonLinkViewModel[] Results { get; set; } 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/PokemonLinkViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace PokeBrowser 2 | { 3 | public class PokemonLinkViewModel : ViewModelBase { 4 | private string _name; 5 | private string _url; 6 | 7 | public string Name 8 | { 9 | get => _name; 10 | set 11 | { 12 | _name = value; 13 | OnPropertyChanged(); 14 | } 15 | } 16 | 17 | public string Url 18 | { 19 | get => _url; 20 | set 21 | { 22 | _url = value; 23 | OnPropertyChanged(); 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/PokemonViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace PokeBrowser 2 | { 3 | public class PokemonViewModel : ViewModelBase 4 | { 5 | private string _name; 6 | private string _type; 7 | private int _height; 8 | private int _weight; 9 | private string _image = ""; 10 | 11 | public string Name 12 | { 13 | get => _name; 14 | set 15 | { 16 | _name = value; 17 | OnPropertyChanged(); 18 | } 19 | } 20 | 21 | public string Type 22 | { 23 | get => _type; 24 | set 25 | { 26 | _type = value; 27 | OnPropertyChanged(); 28 | } 29 | } 30 | 31 | public int Height 32 | { 33 | get => _height; 34 | set 35 | { 36 | _height = value; 37 | OnPropertyChanged(); 38 | } 39 | } 40 | 41 | public int Weight 42 | { 43 | get => _weight; 44 | set 45 | { 46 | _weight = value; 47 | OnPropertyChanged(); 48 | } 49 | } 50 | 51 | public string Image 52 | { 53 | get => _image; 54 | set 55 | { 56 | _image = value; 57 | OnPropertyChanged(); 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspChildControlTypeAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] 6 | public sealed class AspChildControlTypeAttribute : Attribute 7 | { 8 | public AspChildControlTypeAttribute([NotNull] string tagName, [NotNull] Type controlType) 9 | { 10 | TagName = tagName; 11 | ControlType = controlType; 12 | } 13 | 14 | [NotNull] public string TagName { get; private set; } 15 | 16 | [NotNull] public Type ControlType { get; private set; } 17 | } 18 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspDataFieldAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] 6 | public sealed class AspDataFieldAttribute : Attribute { } 7 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspDataFieldsAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] 6 | public sealed class AspDataFieldsAttribute : Attribute { } 7 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMethodPropertyAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Property)] 6 | public sealed class AspMethodPropertyAttribute : Attribute { } 7 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMvcActionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter 7 | /// is an MVC action. If applied to a method, the MVC action name is calculated 8 | /// implicitly from the context. Use this attribute for custom wrappers similar to 9 | /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). 10 | /// 11 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 12 | public sealed class AspMvcActionAttribute : Attribute 13 | { 14 | public AspMvcActionAttribute() { } 15 | 16 | public AspMvcActionAttribute([NotNull] string anonymousProperty) 17 | { 18 | AnonymousProperty = anonymousProperty; 19 | } 20 | 21 | [CanBeNull] public string AnonymousProperty { get; private set; } 22 | } 23 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMvcActionSelectorAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. When applied to a parameter of an attribute, 7 | /// indicates that this parameter is an MVC action name. 8 | /// 9 | /// 10 | /// [ActionName("Foo")] 11 | /// public ActionResult Login(string returnUrl) { 12 | /// ViewBag.ReturnUrl = Url.Action("Foo"); // OK 13 | /// return RedirectToAction("Bar"); // Error: Cannot resolve action 14 | /// } 15 | /// 16 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)] 17 | public sealed class AspMvcActionSelectorAttribute : Attribute { } 18 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMvcAreaAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC area. 7 | /// Use this attribute for custom wrappers similar to 8 | /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). 9 | /// 10 | [AttributeUsage(AttributeTargets.Parameter)] 11 | public sealed class AspMvcAreaAttribute : Attribute 12 | { 13 | public AspMvcAreaAttribute() { } 14 | 15 | public AspMvcAreaAttribute([NotNull] string anonymousProperty) 16 | { 17 | AnonymousProperty = anonymousProperty; 18 | } 19 | 20 | [CanBeNull] public string AnonymousProperty { get; private set; } 21 | } 22 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMvcAreaMasterLocationFormatAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] 6 | public sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute 7 | { 8 | public AspMvcAreaMasterLocationFormatAttribute([NotNull] string format) 9 | { 10 | Format = format; 11 | } 12 | 13 | [NotNull] public string Format { get; private set; } 14 | } 15 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMvcAreaPartialViewLocationFormatAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] 6 | public sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute 7 | { 8 | public AspMvcAreaPartialViewLocationFormatAttribute([NotNull] string format) 9 | { 10 | Format = format; 11 | } 12 | 13 | [NotNull] public string Format { get; private set; } 14 | } 15 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMvcAreaViewLocationFormatAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] 6 | public sealed class AspMvcAreaViewLocationFormatAttribute : Attribute 7 | { 8 | public AspMvcAreaViewLocationFormatAttribute([NotNull] string format) 9 | { 10 | Format = format; 11 | } 12 | 13 | [NotNull] public string Format { get; private set; } 14 | } 15 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMvcControllerAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is 7 | /// an MVC controller. If applied to a method, the MVC controller name is calculated 8 | /// implicitly from the context. Use this attribute for custom wrappers similar to 9 | /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String). 10 | /// 11 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 12 | public sealed class AspMvcControllerAttribute : Attribute 13 | { 14 | public AspMvcControllerAttribute() { } 15 | 16 | public AspMvcControllerAttribute([NotNull] string anonymousProperty) 17 | { 18 | AnonymousProperty = anonymousProperty; 19 | } 20 | 21 | [CanBeNull] public string AnonymousProperty { get; private set; } 22 | } 23 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMvcDisplayTemplateAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template. 7 | /// Use this attribute for custom wrappers similar to 8 | /// System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String). 9 | /// 10 | [AttributeUsage(AttributeTargets.Parameter)] 11 | public sealed class AspMvcDisplayTemplateAttribute : Attribute { } 12 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMvcEditorTemplateAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC editor template. 7 | /// Use this attribute for custom wrappers similar to 8 | /// System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String). 9 | /// 10 | [AttributeUsage(AttributeTargets.Parameter)] 11 | public sealed class AspMvcEditorTemplateAttribute : Attribute { } 12 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMvcMasterAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC Master. Use this attribute 7 | /// for custom wrappers similar to System.Web.Mvc.Controller.View(String, String). 8 | /// 9 | [AttributeUsage(AttributeTargets.Parameter)] 10 | public sealed class AspMvcMasterAttribute : Attribute { } 11 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMvcMasterLocationFormatAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] 6 | public sealed class AspMvcMasterLocationFormatAttribute : Attribute 7 | { 8 | public AspMvcMasterLocationFormatAttribute([NotNull] string format) 9 | { 10 | Format = format; 11 | } 12 | 13 | [NotNull] public string Format { get; private set; } 14 | } 15 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMvcModelTypeAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC model type. Use this attribute 7 | /// for custom wrappers similar to System.Web.Mvc.Controller.View(String, Object). 8 | /// 9 | [AttributeUsage(AttributeTargets.Parameter)] 10 | public sealed class AspMvcModelTypeAttribute : Attribute { } 11 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMvcPartialViewAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC 7 | /// partial view. If applied to a method, the MVC partial view name is calculated implicitly 8 | /// from the context. Use this attribute for custom wrappers similar to 9 | /// System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String). 10 | /// 11 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 12 | public sealed class AspMvcPartialViewAttribute : Attribute { } 13 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMvcPartialViewLocationFormatAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] 6 | public sealed class AspMvcPartialViewLocationFormatAttribute : Attribute 7 | { 8 | public AspMvcPartialViewLocationFormatAttribute([NotNull] string format) 9 | { 10 | Format = format; 11 | } 12 | 13 | [NotNull] public string Format { get; private set; } 14 | } 15 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMvcSuppressViewErrorAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method. 7 | /// 8 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] 9 | public sealed class AspMvcSuppressViewErrorAttribute : Attribute { } 10 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMvcTemplateAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC template. 7 | /// Use this attribute for custom wrappers similar to 8 | /// System.ComponentModel.DataAnnotations.UIHintAttribute(System.String). 9 | /// 10 | [AttributeUsage(AttributeTargets.Parameter)] 11 | public sealed class AspMvcTemplateAttribute : Attribute { } 12 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMvcViewAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter 7 | /// is an MVC view component. If applied to a method, the MVC view name is calculated implicitly 8 | /// from the context. Use this attribute for custom wrappers similar to 9 | /// System.Web.Mvc.Controller.View(Object). 10 | /// 11 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 12 | public sealed class AspMvcViewAttribute : Attribute { } 13 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMvcViewComponentAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter 7 | /// is an MVC view component name. 8 | /// 9 | [AttributeUsage(AttributeTargets.Parameter)] 10 | public sealed class AspMvcViewComponentAttribute : Attribute { } 11 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMvcViewComponentViewAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter 7 | /// is an MVC view component view. If applied to a method, the MVC view component view name is default. 8 | /// 9 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 10 | public sealed class AspMvcViewComponentViewAttribute : Attribute { } 11 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspMvcViewLocationFormatAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] 6 | public sealed class AspMvcViewLocationFormatAttribute : Attribute 7 | { 8 | public AspMvcViewLocationFormatAttribute([NotNull] string format) 9 | { 10 | Format = format; 11 | } 12 | 13 | [NotNull] public string Format { get; private set; } 14 | } 15 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspRequiredAttributeAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] 6 | public sealed class AspRequiredAttributeAttribute : Attribute 7 | { 8 | public AspRequiredAttributeAttribute([NotNull] string attribute) 9 | { 10 | Attribute = attribute; 11 | } 12 | 13 | [NotNull] public string Attribute { get; private set; } 14 | } 15 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AspTypePropertyAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Property)] 6 | public sealed class AspTypePropertyAttribute : Attribute 7 | { 8 | public bool CreateConstructorReferences { get; private set; } 9 | 10 | public AspTypePropertyAttribute(bool createConstructorReferences) 11 | { 12 | CreateConstructorReferences = createConstructorReferences; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("pokemonapp")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("pokemonapp")] 15 | [assembly: AssemblyCopyright("Copyright © 2019")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AssertionConditionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Indicates the condition parameter of the assertion method. The method itself should be 7 | /// marked by attribute. The mandatory argument of 8 | /// the attribute is the assertion type. 9 | /// 10 | [AttributeUsage(AttributeTargets.Parameter)] 11 | public sealed class AssertionConditionAttribute : Attribute 12 | { 13 | public AssertionConditionAttribute(AssertionConditionType conditionType) 14 | { 15 | ConditionType = conditionType; 16 | } 17 | 18 | public AssertionConditionType ConditionType { get; private set; } 19 | } 20 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AssertionConditionType.cs: -------------------------------------------------------------------------------- 1 | namespace PokeBrowser.Properties 2 | { 3 | /// 4 | /// Specifies assertion type. If the assertion method argument satisfies the condition, 5 | /// then the execution continues. Otherwise, execution is assumed to be halted. 6 | /// 7 | public enum AssertionConditionType 8 | { 9 | /// Marked parameter should be evaluated to true. 10 | IS_TRUE = 0, 11 | /// Marked parameter should be evaluated to false. 12 | IS_FALSE = 1, 13 | /// Marked parameter should be evaluated to null value. 14 | IS_NULL = 2, 15 | /// Marked parameter should be evaluated to not null value. 16 | IS_NOT_NULL = 3, 17 | } 18 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/AssertionMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Indicates that the marked method is assertion method, i.e. it halts control flow if 7 | /// one of the conditions is satisfied. To set the condition, mark one of the parameters with 8 | /// attribute. 9 | /// 10 | [AttributeUsage(AttributeTargets.Method)] 11 | public sealed class AssertionMethodAttribute : Attribute { } 12 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/BaseTypeRequiredAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// When applied to a target attribute, specifies a requirement for any type marked 7 | /// with the target attribute to implement or inherit specific type or types. 8 | /// 9 | /// 10 | /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement 11 | /// class ComponentAttribute : Attribute { } 12 | /// 13 | /// [Component] // ComponentAttribute requires implementing IComponent interface 14 | /// class MyComponent : IComponent { } 15 | /// 16 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] 17 | [BaseTypeRequired(typeof(Attribute))] 18 | public sealed class BaseTypeRequiredAttribute : Attribute 19 | { 20 | public BaseTypeRequiredAttribute([NotNull] Type baseType) 21 | { 22 | BaseType = baseType; 23 | } 24 | 25 | [NotNull] public Type BaseType { get; private set; } 26 | } 27 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/CanBeNullAttribute.cs: -------------------------------------------------------------------------------- 1 | /* MIT License 2 | 3 | Copyright (c) 2016 JetBrains http://www.jetbrains.com 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 | 23 | using System; 24 | 25 | #pragma warning disable 1591 26 | // ReSharper disable UnusedMember.Global 27 | // ReSharper disable MemberCanBePrivate.Global 28 | // ReSharper disable UnusedAutoPropertyAccessor.Global 29 | // ReSharper disable IntroduceOptionalParameters.Global 30 | // ReSharper disable MemberCanBeProtected.Global 31 | // ReSharper disable InconsistentNaming 32 | 33 | namespace PokeBrowser.Properties 34 | { 35 | /// 36 | /// Indicates that the value of the marked element could be null sometimes, 37 | /// so the check for null is necessary before its usage. 38 | /// 39 | /// 40 | /// [CanBeNull] object Test() => null; 41 | /// 42 | /// void UseTest() { 43 | /// var p = Test(); 44 | /// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException' 45 | /// } 46 | /// 47 | [AttributeUsage( 48 | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | 49 | AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event | 50 | AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)] 51 | public sealed class CanBeNullAttribute : Attribute { } 52 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/CannotApplyEqualityOperatorAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Indicates that the value of the marked type (or its derivatives) 7 | /// cannot be compared using '==' or '!=' operators and Equals() 8 | /// should be used instead. However, using '==' or '!=' for comparison 9 | /// with null is always permitted. 10 | /// 11 | /// 12 | /// [CannotApplyEqualityOperator] 13 | /// class NoEquality { } 14 | /// 15 | /// class UsesNoEquality { 16 | /// void Test() { 17 | /// var ca1 = new NoEquality(); 18 | /// var ca2 = new NoEquality(); 19 | /// if (ca1 != null) { // OK 20 | /// bool condition = ca1 == ca2; // Warning 21 | /// } 22 | /// } 23 | /// } 24 | /// 25 | [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)] 26 | public sealed class CannotApplyEqualityOperatorAttribute : Attribute { } 27 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/CollectionAccessAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Indicates how method, constructor invocation or property access 7 | /// over collection type affects content of the collection. 8 | /// 9 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property)] 10 | public sealed class CollectionAccessAttribute : Attribute 11 | { 12 | public CollectionAccessAttribute(CollectionAccessType collectionAccessType) 13 | { 14 | CollectionAccessType = collectionAccessType; 15 | } 16 | 17 | public CollectionAccessType CollectionAccessType { get; private set; } 18 | } 19 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/CollectionAccessType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [Flags] 6 | public enum CollectionAccessType 7 | { 8 | /// Method does not use or modify content of the collection. 9 | None = 0, 10 | /// Method only reads content of the collection but does not modify it. 11 | Read = 1, 12 | /// Method can change content of the collection but does not add new elements. 13 | ModifyExistingContent = 2, 14 | /// Method can add new elements to the collection. 15 | UpdatedContent = ModifyExistingContent | 4 16 | } 17 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/ContractAnnotationAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Describes dependency between method input and output. 7 | /// 8 | /// 9 | ///

Function Definition Table syntax:

10 | /// 11 | /// FDT ::= FDTRow [;FDTRow]* 12 | /// FDTRow ::= Input => Output | Output <= Input 13 | /// Input ::= ParameterName: Value [, Input]* 14 | /// Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value} 15 | /// Value ::= true | false | null | notnull | canbenull 16 | /// 17 | /// If method has single input parameter, it's name could be omitted.
18 | /// Using halt (or void/nothing, which is the same) for method output 19 | /// means that the methos doesn't return normally (throws or terminates the process).
20 | /// Value canbenull is only applicable for output parameters.
21 | /// You can use multiple [ContractAnnotation] for each FDT row, or use single attribute 22 | /// with rows separated by semicolon. There is no notion of order rows, all rows are checked 23 | /// for applicability and applied per each program state tracked by R# analysis.
24 | ///
25 | /// 26 | /// 27 | /// [ContractAnnotation("=> halt")] 28 | /// public void TerminationMethod() 29 | /// 30 | /// 31 | /// [ContractAnnotation("halt <= condition: false")] 32 | /// public void Assert(bool condition, string text) // regular assertion method 33 | /// 34 | /// 35 | /// [ContractAnnotation("s:null => true")] 36 | /// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty() 37 | /// 38 | /// 39 | /// // A method that returns null if the parameter is null, 40 | /// // and not null if the parameter is not null 41 | /// [ContractAnnotation("null => null; notnull => notnull")] 42 | /// public object Transform(object data) 43 | /// 44 | /// 45 | /// [ContractAnnotation("=> true, result: notnull; => false, result: null")] 46 | /// public bool TryParse(string s, out Person result) 47 | /// 48 | /// 49 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] 50 | public sealed class ContractAnnotationAttribute : Attribute 51 | { 52 | public ContractAnnotationAttribute([NotNull] string contract) 53 | : this(contract, false) { } 54 | 55 | public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates) 56 | { 57 | Contract = contract; 58 | ForceFullStates = forceFullStates; 59 | } 60 | 61 | [NotNull] public string Contract { get; private set; } 62 | 63 | public bool ForceFullStates { get; private set; } 64 | } 65 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/HtmlAttributeValueAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)] 6 | public sealed class HtmlAttributeValueAttribute : Attribute 7 | { 8 | public HtmlAttributeValueAttribute([NotNull] string name) 9 | { 10 | Name = name; 11 | } 12 | 13 | [NotNull] public string Name { get; private set; } 14 | } 15 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/HtmlElementAttributesAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)] 6 | public sealed class HtmlElementAttributesAttribute : Attribute 7 | { 8 | public HtmlElementAttributesAttribute() { } 9 | 10 | public HtmlElementAttributesAttribute([NotNull] string name) 11 | { 12 | Name = name; 13 | } 14 | 15 | [CanBeNull] public string Name { get; private set; } 16 | } 17 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/ImplicitUseKindFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [Flags] 6 | public enum ImplicitUseKindFlags 7 | { 8 | Default = Access | Assign | InstantiatedWithFixedConstructorSignature, 9 | /// Only entity marked with attribute considered used. 10 | Access = 1, 11 | /// Indicates implicit assignment to a member. 12 | Assign = 2, 13 | /// 14 | /// Indicates implicit instantiation of a type with fixed constructor signature. 15 | /// That means any unused constructor parameters won't be reported as such. 16 | /// 17 | InstantiatedWithFixedConstructorSignature = 4, 18 | /// Indicates implicit instantiation of a type. 19 | InstantiatedNoFixedConstructorSignature = 8, 20 | } 21 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/ImplicitUseTargetFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Specify what is considered used implicitly when marked 7 | /// with or . 8 | /// 9 | [Flags] 10 | public enum ImplicitUseTargetFlags 11 | { 12 | Default = Itself, 13 | Itself = 1, 14 | /// Members of entity marked with attribute are considered used. 15 | Members = 2, 16 | /// Entity marked with attribute and all its members considered used. 17 | WithMembers = Itself | Members 18 | } 19 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/InstantHandleAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Tells code analysis engine if the parameter is completely handled when the invoked method is on stack. 7 | /// If the parameter is a delegate, indicates that delegate is executed while the method is executed. 8 | /// If the parameter is an enumerable, indicates that it is enumerated while the method is executed. 9 | /// 10 | [AttributeUsage(AttributeTargets.Parameter)] 11 | public sealed class InstantHandleAttribute : Attribute { } 12 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/InvokerParameterNameAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Indicates that the function argument should be string literal and match one 7 | /// of the parameters of the caller function. For example, ReSharper annotates 8 | /// the parameter of . 9 | /// 10 | /// 11 | /// void Foo(string param) { 12 | /// if (param == null) 13 | /// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol 14 | /// } 15 | /// 16 | [AttributeUsage(AttributeTargets.Parameter)] 17 | public sealed class InvokerParameterNameAttribute : Attribute { } 18 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/ItemCanBeNullAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task 7 | /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property 8 | /// or of the Lazy.Value property can be null. 9 | /// 10 | [AttributeUsage( 11 | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | 12 | AttributeTargets.Delegate | AttributeTargets.Field)] 13 | public sealed class ItemCanBeNullAttribute : Attribute { } 14 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/ItemNotNullAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task 7 | /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property 8 | /// or of the Lazy.Value property can never be null. 9 | /// 10 | [AttributeUsage( 11 | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | 12 | AttributeTargets.Delegate | AttributeTargets.Field)] 13 | public sealed class ItemNotNullAttribute : Attribute { } 14 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/LinqTunnelAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Indicates that method is pure LINQ method, with postponed enumeration (like Enumerable.Select, 7 | /// .Where). This annotation allows inference of [InstantHandle] annotation for parameters 8 | /// of delegate type by analyzing LINQ method chains. 9 | /// 10 | [AttributeUsage(AttributeTargets.Method)] 11 | public sealed class LinqTunnelAttribute : Attribute { } 12 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/LocalizationRequiredAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Indicates that marked element should be localized or not. 7 | /// 8 | /// 9 | /// [LocalizationRequiredAttribute(true)] 10 | /// class Foo { 11 | /// string str = "my string"; // Warning: Localizable string 12 | /// } 13 | /// 14 | [AttributeUsage(AttributeTargets.All)] 15 | public sealed class LocalizationRequiredAttribute : Attribute 16 | { 17 | public LocalizationRequiredAttribute() : this(true) { } 18 | 19 | public LocalizationRequiredAttribute(bool required) 20 | { 21 | Required = required; 22 | } 23 | 24 | public bool Required { get; private set; } 25 | } 26 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/MacroAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Allows specifying a macro for a parameter of a source template. 7 | /// 8 | /// 9 | /// You can apply the attribute on the whole method or on any of its additional parameters. The macro expression 10 | /// is defined in the property. When applied on a method, the target 11 | /// template parameter is defined in the property. To apply the macro silently 12 | /// for the parameter, set the property value = -1. 13 | /// 14 | /// 15 | /// Applying the attribute on a source template method: 16 | /// 17 | /// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")] 18 | /// public static void forEach<T>(this IEnumerable<T> collection) { 19 | /// foreach (var item in collection) { 20 | /// //$ $END$ 21 | /// } 22 | /// } 23 | /// 24 | /// Applying the attribute on a template method parameter: 25 | /// 26 | /// [SourceTemplate] 27 | /// public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) { 28 | /// /*$ var $x$Id = "$newguid$" + x.ToString(); 29 | /// x.DoSomething($x$Id); */ 30 | /// } 31 | /// 32 | /// 33 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, AllowMultiple = true)] 34 | public sealed class MacroAttribute : Attribute 35 | { 36 | /// 37 | /// Allows specifying a macro that will be executed for a source template 38 | /// parameter when the template is expanded. 39 | /// 40 | [CanBeNull] public string Expression { get; set; } 41 | 42 | /// 43 | /// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed. 44 | /// 45 | /// 46 | /// If the target parameter is used several times in the template, only one occurrence becomes editable; 47 | /// other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence, 48 | /// use values >= 0. To make the parameter non-editable when the template is expanded, use -1. 49 | /// > 50 | public int Editable { get; set; } 51 | 52 | /// 53 | /// Identifies the target parameter of a source template if the 54 | /// is applied on a template method. 55 | /// 56 | [CanBeNull] public string Target { get; set; } 57 | } 58 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/MeansImplicitUseAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Should be used on attributes and causes ReSharper to not mark symbols marked with such attributes 7 | /// as unused (as well as by other usage inspections) 8 | /// 9 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.GenericParameter)] 10 | public sealed class MeansImplicitUseAttribute : Attribute 11 | { 12 | public MeansImplicitUseAttribute() 13 | : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { } 14 | 15 | public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags) 16 | : this(useKindFlags, ImplicitUseTargetFlags.Default) { } 17 | 18 | public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags) 19 | : this(ImplicitUseKindFlags.Default, targetFlags) { } 20 | 21 | public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) 22 | { 23 | UseKindFlags = useKindFlags; 24 | TargetFlags = targetFlags; 25 | } 26 | 27 | [UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; private set; } 28 | 29 | [UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; private set; } 30 | } 31 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/MustUseReturnValueAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Indicates that the return value of method invocation must be used. 7 | /// 8 | [AttributeUsage(AttributeTargets.Method)] 9 | public sealed class MustUseReturnValueAttribute : Attribute 10 | { 11 | public MustUseReturnValueAttribute() { } 12 | 13 | public MustUseReturnValueAttribute([NotNull] string justification) 14 | { 15 | Justification = justification; 16 | } 17 | 18 | [CanBeNull] public string Justification { get; private set; } 19 | } 20 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/NoEnumerationAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Indicates that IEnumerable, passed as parameter, is not enumerated. 7 | /// 8 | [AttributeUsage(AttributeTargets.Parameter)] 9 | public sealed class NoEnumerationAttribute : Attribute { } 10 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/NoReorderAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Prevents the Member Reordering feature from tossing members of the marked class. 7 | /// 8 | /// 9 | /// The attribute must be mentioned in your member reordering patterns 10 | /// 11 | [AttributeUsage( 12 | AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum)] 13 | public sealed class NoReorderAttribute : Attribute { } 14 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/NotNullAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Indicates that the value of the marked element could never be null. 7 | /// 8 | /// 9 | /// [NotNull] object Foo() { 10 | /// return null; // Warning: Possible 'null' assignment 11 | /// } 12 | /// 13 | [AttributeUsage( 14 | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | 15 | AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event | 16 | AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)] 17 | public sealed class NotNullAttribute : Attribute { } 18 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/NotifyPropertyChangedInvocatorAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Indicates that the method is contained in a type that implements 7 | /// System.ComponentModel.INotifyPropertyChanged interface and this method 8 | /// is used to notify that some property value changed. 9 | /// 10 | /// 11 | /// The method should be non-static and conform to one of the supported signatures: 12 | /// 13 | /// NotifyChanged(string) 14 | /// NotifyChanged(params string[]) 15 | /// NotifyChanged{T}(Expression{Func{T}}) 16 | /// NotifyChanged{T,U}(Expression{Func{T,U}}) 17 | /// SetProperty{T}(ref T, T, string) 18 | /// 19 | /// 20 | /// 21 | /// public class Foo : INotifyPropertyChanged { 22 | /// public event PropertyChangedEventHandler PropertyChanged; 23 | /// 24 | /// [NotifyPropertyChangedInvocator] 25 | /// protected virtual void NotifyChanged(string propertyName) { ... } 26 | /// 27 | /// string _name; 28 | /// 29 | /// public string Name { 30 | /// get { return _name; } 31 | /// set { _name = value; NotifyChanged("LastName"); /* Warning */ } 32 | /// } 33 | /// } 34 | /// 35 | /// Examples of generated notifications: 36 | /// 37 | /// NotifyChanged("Property") 38 | /// NotifyChanged(() => Property) 39 | /// NotifyChanged((VM x) => x.Property) 40 | /// SetProperty(ref myField, value, "Property") 41 | /// 42 | /// 43 | [AttributeUsage(AttributeTargets.Method)] 44 | public sealed class NotifyPropertyChangedInvocatorAttribute : Attribute 45 | { 46 | public NotifyPropertyChangedInvocatorAttribute() { } 47 | public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName) 48 | { 49 | ParameterName = parameterName; 50 | } 51 | 52 | [CanBeNull] public string ParameterName { get; private set; } 53 | } 54 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/PathReferenceAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Indicates that a parameter is a path to a file or a folder within a web project. 7 | /// Path can be relative or absolute, starting from web root (~). 8 | /// 9 | [AttributeUsage(AttributeTargets.Parameter)] 10 | public sealed class PathReferenceAttribute : Attribute 11 | { 12 | public PathReferenceAttribute() { } 13 | 14 | public PathReferenceAttribute([NotNull, PathReference] string basePath) 15 | { 16 | BasePath = basePath; 17 | } 18 | 19 | [CanBeNull] public string BasePath { get; private set; } 20 | } 21 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/ProvidesContextAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Indicates the type member or parameter of some type, that should be used instead of all other ways 7 | /// to get the value that type. This annotation is useful when you have some "context" value evaluated 8 | /// and stored somewhere, meaning that all other ways to get this value must be consolidated with existing one. 9 | /// 10 | /// 11 | /// class Foo { 12 | /// [ProvidesContext] IBarService _barService = ...; 13 | /// 14 | /// void ProcessNode(INode node) { 15 | /// DoSomething(node, node.GetGlobalServices().Bar); 16 | /// // ^ Warning: use value of '_barService' field 17 | /// } 18 | /// } 19 | /// 20 | [AttributeUsage( 21 | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.Method | 22 | AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.GenericParameter)] 23 | public sealed class ProvidesContextAttribute : Attribute { } 24 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/PublicAPIAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// This attribute is intended to mark publicly available API 7 | /// which should not be removed and so is treated as used. 8 | /// 9 | [MeansImplicitUse(ImplicitUseTargetFlags.WithMembers)] 10 | public sealed class PublicAPIAttribute : Attribute 11 | { 12 | public PublicAPIAttribute() { } 13 | 14 | public PublicAPIAttribute([NotNull] string comment) 15 | { 16 | Comment = comment; 17 | } 18 | 19 | [CanBeNull] public string Comment { get; private set; } 20 | } 21 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/PureAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Indicates that a method does not make any observable state changes. 7 | /// The same as System.Diagnostics.Contracts.PureAttribute. 8 | /// 9 | /// 10 | /// [Pure] int Multiply(int x, int y) => x * y; 11 | /// 12 | /// void M() { 13 | /// Multiply(123, 42); // Waring: Return value of pure method is not used 14 | /// } 15 | /// 16 | [AttributeUsage(AttributeTargets.Method)] 17 | public sealed class PureAttribute : Attribute { } 18 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/RazorDirectiveAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 6 | public sealed class RazorDirectiveAttribute : Attribute 7 | { 8 | public RazorDirectiveAttribute([NotNull] string directive) 9 | { 10 | Directive = directive; 11 | } 12 | 13 | [NotNull] public string Directive { get; private set; } 14 | } 15 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/RazorHelperCommonAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Method)] 6 | public sealed class RazorHelperCommonAttribute : Attribute { } 7 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/RazorImportNamespaceAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 6 | public sealed class RazorImportNamespaceAttribute : Attribute 7 | { 8 | public RazorImportNamespaceAttribute([NotNull] string name) 9 | { 10 | Name = name; 11 | } 12 | 13 | [NotNull] public string Name { get; private set; } 14 | } 15 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/RazorInjectionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 6 | public sealed class RazorInjectionAttribute : Attribute 7 | { 8 | public RazorInjectionAttribute([NotNull] string type, [NotNull] string fieldName) 9 | { 10 | Type = type; 11 | FieldName = fieldName; 12 | } 13 | 14 | [NotNull] public string Type { get; private set; } 15 | 16 | [NotNull] public string FieldName { get; private set; } 17 | } 18 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/RazorLayoutAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Property)] 6 | public sealed class RazorLayoutAttribute : Attribute { } 7 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/RazorPageBaseTypeAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 6 | public sealed class RazorPageBaseTypeAttribute : Attribute 7 | { 8 | public RazorPageBaseTypeAttribute([NotNull] string baseType) 9 | { 10 | BaseType = baseType; 11 | } 12 | public RazorPageBaseTypeAttribute([NotNull] string baseType, string pageName) 13 | { 14 | BaseType = baseType; 15 | PageName = pageName; 16 | } 17 | 18 | [NotNull] public string BaseType { get; private set; } 19 | [CanBeNull] public string PageName { get; private set; } 20 | } 21 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/RazorSectionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Razor attribute. Indicates that a parameter or a method is a Razor section. 7 | /// Use this attribute for custom wrappers similar to 8 | /// System.Web.WebPages.WebPageBase.RenderSection(String). 9 | /// 10 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 11 | public sealed class RazorSectionAttribute : Attribute { } 12 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/RazorWriteLiteralMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Method)] 6 | public sealed class RazorWriteLiteralMethodAttribute : Attribute { } 7 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/RazorWriteMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Method)] 6 | public sealed class RazorWriteMethodAttribute : Attribute { } 7 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/RazorWriteMethodParameterAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | [AttributeUsage(AttributeTargets.Parameter)] 6 | public sealed class RazorWriteMethodParameterAttribute : Attribute { } 7 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/RegexPatternAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Indicates that parameter is regular expression pattern. 7 | /// 8 | [AttributeUsage(AttributeTargets.Parameter)] 9 | public sealed class RegexPatternAttribute : Attribute { } 10 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace PokeBrowser.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PokeBrowser.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace PokeBrowser.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/SourceTemplateAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// An extension method marked with this attribute is processed by ReSharper code completion 7 | /// as a 'Source Template'. When extension method is completed over some expression, it's source code 8 | /// is automatically expanded like a template at call site. 9 | /// 10 | /// 11 | /// Template method body can contain valid source code and/or special comments starting with '$'. 12 | /// Text inside these comments is added as source code when the template is applied. Template parameters 13 | /// can be used either as additional method parameters or as identifiers wrapped in two '$' signs. 14 | /// Use the attribute to specify macros for parameters. 15 | /// 16 | /// 17 | /// In this example, the 'forEach' method is a source template available over all values 18 | /// of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block: 19 | /// 20 | /// [SourceTemplate] 21 | /// public static void forEach<T>(this IEnumerable<T> xs) { 22 | /// foreach (var x in xs) { 23 | /// //$ $END$ 24 | /// } 25 | /// } 26 | /// 27 | /// 28 | [AttributeUsage(AttributeTargets.Method)] 29 | public sealed class SourceTemplateAttribute : Attribute { } 30 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/StringFormatMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Indicates that the marked method builds string by format pattern and (optional) arguments. 7 | /// Parameter, which contains format string, should be given in constructor. The format string 8 | /// should be in -like form. 9 | /// 10 | /// 11 | /// [StringFormatMethod("message")] 12 | /// void ShowError(string message, params object[] args) { /* do something */ } 13 | /// 14 | /// void Foo() { 15 | /// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string 16 | /// } 17 | /// 18 | [AttributeUsage( 19 | AttributeTargets.Constructor | AttributeTargets.Method | 20 | AttributeTargets.Property | AttributeTargets.Delegate)] 21 | public sealed class StringFormatMethodAttribute : Attribute 22 | { 23 | /// 24 | /// Specifies which parameter of an annotated method should be treated as format-string 25 | /// 26 | public StringFormatMethodAttribute([NotNull] string formatParameterName) 27 | { 28 | FormatParameterName = formatParameterName; 29 | } 30 | 31 | [NotNull] public string FormatParameterName { get; private set; } 32 | } 33 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/TerminatesProgramAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Indicates that the marked method unconditionally terminates control flow execution. 7 | /// For example, it could unconditionally throw exception. 8 | /// 9 | [Obsolete("Use [ContractAnnotation('=> halt')] instead")] 10 | [AttributeUsage(AttributeTargets.Method)] 11 | public sealed class TerminatesProgramAttribute : Attribute { } 12 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/UsedImplicitlyAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library), 7 | /// so this symbol will not be marked as unused (as well as by other usage inspections). 8 | /// 9 | [AttributeUsage(AttributeTargets.All)] 10 | public sealed class UsedImplicitlyAttribute : Attribute 11 | { 12 | public UsedImplicitlyAttribute() 13 | : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { } 14 | 15 | public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags) 16 | : this(useKindFlags, ImplicitUseTargetFlags.Default) { } 17 | 18 | public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags) 19 | : this(ImplicitUseKindFlags.Default, targetFlags) { } 20 | 21 | public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) 22 | { 23 | UseKindFlags = useKindFlags; 24 | TargetFlags = targetFlags; 25 | } 26 | 27 | public ImplicitUseKindFlags UseKindFlags { get; private set; } 28 | 29 | public ImplicitUseTargetFlags TargetFlags { get; private set; } 30 | } 31 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/ValueProviderAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// For a parameter that is expected to be one of the limited set of values. 7 | /// Specify fields of which type should be used as values for this parameter. 8 | /// 9 | [AttributeUsage( 10 | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field, 11 | AllowMultiple = true)] 12 | public sealed class ValueProviderAttribute : Attribute 13 | { 14 | public ValueProviderAttribute([NotNull] string name) 15 | { 16 | Name = name; 17 | } 18 | 19 | [NotNull] public string Name { get; private set; } 20 | } 21 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/XamlItemBindingOfItemsControlAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// XAML attribute. Indicates the property of some BindingBase-derived type, that 7 | /// is used to bind some item of ItemsControl-derived type. This annotation will 8 | /// enable the DataContext type resolve for XAML bindings for such properties. 9 | /// 10 | /// 11 | /// Property should have the tree ancestor of the ItemsControl type or 12 | /// marked with the attribute. 13 | /// 14 | [AttributeUsage(AttributeTargets.Property)] 15 | public sealed class XamlItemBindingOfItemsControlAttribute : Attribute { } 16 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/Properties/XamlItemsControlAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PokeBrowser.Properties 4 | { 5 | /// 6 | /// XAML attribute. Indicates the type that has ItemsSource property and should be treated 7 | /// as ItemsControl-derived type, to enable inner items DataContext type resolve. 8 | /// 9 | [AttributeUsage(AttributeTargets.Class)] 10 | public sealed class XamlItemsControlAttribute : Attribute { } 11 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/RelayCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Input; 3 | 4 | namespace PokeBrowser 5 | { 6 | public class RelayCommand : ICommand 7 | { 8 | private Action execute; 9 | private Func canExecute; 10 | 11 | public event EventHandler CanExecuteChanged 12 | { 13 | add { CommandManager.RequerySuggested += value; } 14 | remove { CommandManager.RequerySuggested -= value; } 15 | } 16 | 17 | public RelayCommand(Action execute, Func canExecute = null) 18 | { 19 | this.execute = execute; 20 | this.canExecute = canExecute; 21 | } 22 | 23 | public bool CanExecute(object parameter) 24 | { 25 | return this.canExecute == null || this.canExecute(parameter); 26 | } 27 | 28 | public void Execute(object parameter) 29 | { 30 | this.execute(parameter); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/ViewModelBase.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Runtime.CompilerServices; 3 | using PokeBrowser.Properties; 4 | 5 | namespace PokeBrowser 6 | { 7 | public class ViewModelBase : INotifyPropertyChanged 8 | { 9 | public event PropertyChangedEventHandler PropertyChanged; 10 | 11 | [NotifyPropertyChangedInvocator] 12 | public virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) 13 | { 14 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Csharp/PokeBrowser/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /demo/PokeBrowser.Ps/MainView.ps1: -------------------------------------------------------------------------------- 1 | [string]$xaml = @" 2 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | Select Pokemon: 13 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Weight 24 | 25 | 26 | Height 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 50 | 54 | 57 | 58 | 59 | "@ 60 | 61 | -------------------------------------------------------------------------------- /demo/PokeBrowser.Ps/MainViewModel.ps1: -------------------------------------------------------------------------------- 1 | class MainViewModel : WpfToolkit.ViewModelBase { 2 | [Windows.Input.ICommand] $Refresh 3 | [Windows.Input.ICommand] $Show 4 | 5 | # suprisingly it works without actual types 6 | $PokemonList 7 | $Selected 8 | $Detail 9 | 10 | [Windows.Visibility] $ProgressVisibility 11 | 12 | [String] $_root = $PSScriptRoot 13 | 14 | MainViewModel () { 15 | $this.Init('PokemonList') 16 | $this.Init('Selected') 17 | $this.Init('Detail') 18 | $this.Init('ProgressVisibility') 19 | $this.SetProgressVisibility('Hidden') 20 | 21 | $doRefresh = { 22 | param($this, $o) 23 | 24 | try { 25 | Dispatch { $this.SetProgressVisibility("Visible") } 26 | 27 | . "$($this._root)/Tasks.ps1" 28 | $pokemon = Get-Pokemon 29 | Start-Sleep -Seconds 1 30 | 31 | $this.SetPokemonList($pokemon) 32 | $this.SetSelected(($pokemon | Select -First 1)) 33 | } 34 | finally { 35 | Dispatch { $this.SetProgressVisibility('Hidden') } 36 | } 37 | } 38 | 39 | $doShow = { 40 | param($this, $o) 41 | 42 | try { 43 | Dispatch { $this.SetProgressVisibility("Visible") } 44 | 45 | . "$($this._root)/Tasks.ps1" 46 | $pokemon = Get-PokemonDetail ($this.Selected.Url) 47 | 48 | Start-Sleep -Seconds 1 49 | 50 | $this.SetDetail($pokemon) 51 | } 52 | finally { 53 | Dispatch { $this.SetProgressVisibility('Hidden') } 54 | } 55 | } 56 | 57 | 58 | $this.Refresh = $this.NewBackgroundCommand($doRefresh, {}) 59 | 60 | $this.Show = $this.NewBackgroundCommand($doShow, {}) 61 | } 62 | } 63 | 64 | -------------------------------------------------------------------------------- /demo/PokeBrowser.Ps/PokeBrowser.ps1: -------------------------------------------------------------------------------- 1 | $DebugPreference = 'continue' 2 | . "$PSScriptRoot\..\..\wpf.ps1" 3 | 4 | . "$PSScriptRoot\Tasks.ps1" 5 | 6 | . "$PSScriptRoot\PokemonViewModel.ps1" 7 | 8 | . "$PSScriptRoot\PokemonLinkViewModel.ps1" 9 | 10 | . "$PSScriptRoot\MainView.ps1" 11 | . "$PSScriptRoot\MainViewModel.ps1" 12 | 13 | $DebugPreference = 'continue' 14 | 15 | [Diagnostics.PresentationTraceSources]::Refresh() 16 | [Diagnostics.PresentationTraceSources]::DataBindingSource.Listeners.Add([Diagnostics.ConsoleTraceListener]::new()) 17 | [Diagnostics.PresentationTraceSources]::DataBindingSource.Switch.Level = "Warning, Error" 18 | 19 | 20 | $Window=[Windows.Markup.XamlReader]::Parse($xaml) 21 | $Window.DataContext = [MainViewModel]::new() 22 | $Window.ShowDialog() -------------------------------------------------------------------------------- /demo/PokeBrowser.Ps/PokemonLinkViewModel.ps1: -------------------------------------------------------------------------------- 1 | class PokemonLinkViewModel : WpfToolkit.ViewModelBase { 2 | [string] $Name 3 | [string] $Url 4 | 5 | PokemonLinkViewModel () { 6 | Write-Host "Constructing Main view Model" 7 | 8 | $this.Init('Name') 9 | $this.Init('Url') 10 | } 11 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Ps/PokemonViewModel.ps1: -------------------------------------------------------------------------------- 1 | class PokemonViewModel : WpfToolkit.ViewModelBase { 2 | [string] $Name 3 | [int] $Weight 4 | [int] $Height 5 | [string] $Type 6 | [string] $Image 7 | 8 | PokemonLinkViewModel () { 9 | Write-Host "Constructing Main view Model" 10 | 11 | $this.Init('Name') 12 | $this.Init('Weight') 13 | $this.Init('Height') 14 | $this.Init('Type') 15 | $this.Init('Image') 16 | } 17 | } -------------------------------------------------------------------------------- /demo/PokeBrowser.Ps/Tasks.ps1: -------------------------------------------------------------------------------- 1 | function Get-Pokemon { 2 | $url = "https://pokeapi.co/api/v2/pokemon/?limit=300" 3 | $response = Invoke-RestMethod -Uri $url 4 | 5 | $response.Results | foreach { [PsCustomObject]$_ } 6 | } 7 | 8 | 9 | function Get-PokemonDetail ($Url) { 10 | $response = Invoke-RestMethod -Uri $url 11 | 12 | [PSCustomObject]@{ 13 | Name = $response.name 14 | Height = $response.Height 15 | Weight = $response.weight 16 | Type = $response.types[0].type.name 17 | Image = $response.sprites.front_default 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /doc/View.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nohwnd/WpfToolkit/fa2afa1326ebfc376134a31b934df017c231c4a0/doc/View.PNG -------------------------------------------------------------------------------- /doc/ViewModel.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nohwnd/WpfToolkit/fa2afa1326ebfc376134a31b934df017c231c4a0/doc/ViewModel.PNG -------------------------------------------------------------------------------- /doc/mvvmpowershell.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nohwnd/WpfToolkit/fa2afa1326ebfc376134a31b934df017c231c4a0/doc/mvvmpowershell.gif -------------------------------------------------------------------------------- /eventcallbacks.ps1: -------------------------------------------------------------------------------- 1 | $asyncCallback = { 2 | Param ( 3 | # Event source object 4 | [System.Management.Automation.Powershell] 5 | $sender, 6 | 7 | # Inheritor of [System.EventArgs] 8 | [System.Management.Automation.PSInvocationStateChangedEventArgs] 9 | $e 10 | ) 11 | 12 | # Ignore initial state change on startup 13 | if ($e.InvocationStateInfo.State -eq [System.Management.Automation.PSInvocationState]::Running) 14 | { 15 | return 16 | } 17 | 18 | Write-Host $sender.Message 19 | Write-Host "Event Fired!" 20 | Write-Host ("Invocation State: {0}" -f $e.InvocationStateInfo.State) 21 | 22 | # Use the NoteProperty references attached to the Powershell object by Add-Member 23 | [void]$sender.EndInvoke($sender.AsyncResult) 24 | $sender.Dispose() 25 | 26 | # 27 | # You can unregister the event from within the event handler, but you 28 | # shouldn't do so if you plan on recycling/restarting the background 29 | # powershell instance. 30 | # 31 | # Unregister the event subscription 32 | Unregister-Event -SourceIdentifier $sender.EventSubscriber.Name 33 | } 34 | 35 | 36 | 37 | 38 | $ps = [PowerShell]::Create() 39 | $rs = [RunspaceFactory]::CreateRunspace() 40 | $rs.Open() 41 | $ps.Runspace = $rs 42 | $ps.AddScript( { 43 | #Get-Service 44 | Get-Process 45 | Start-Sleep -Seconds 2 46 | } ) 47 | 48 | # 49 | # Subscribe to the Powershell state changed event. Attach the registration object 50 | # to the Powershell object for future reference. 51 | # 52 | Add-Member -InputObject $ps -MemberType NoteProperty -Name EventSubscriber -Value ( 53 | Register-ObjectEvent -InputObject $ps -EventName InvocationStateChanged -Action $asyncCallback) 54 | 55 | <# 56 | # This call structure is unnecessary as you aren't using the InvocationSettings 57 | # 58 | # $psis = New-Object Management.Automation.PSInvocationSettings 59 | # $aResult = $ps.BeginInvoke($psdcInputs, $psdcOutputs, $psis, $asyncCallback, $ps) 60 | #> 61 | 62 | Add-Member -InputObject $ps -MemberType NoteProperty -Name Message -Value ( 63 | "Hello World! It's Me {0}" -f $ps.EventSubscriber.Name) 64 | 65 | $psdcInputs = New-Object Management.Automation.PSDataCollection[String] 66 | $psdcInputs.Complete() 67 | $psdcOutputs = New-Object Management.Automation.PSDataCollection[Object] 68 | 69 | Add-Member -InputObject $ps -MemberType NoteProperty -Name AsyncResult -Value ( 70 | $ps.BeginInvoke($psdcInputs, $psdcOutputs)) 71 | 72 | -------------------------------------------------------------------------------- /log.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nohwnd/WpfToolkit/fa2afa1326ebfc376134a31b934df017c231c4a0/log.txt -------------------------------------------------------------------------------- /outsideconfigforBackgroundWorkScript.ps1: -------------------------------------------------------------------------------- 1 | # command that runs on background 2 | $work = { 3 | param($this, $o) 4 | 5 | "$(Get-Date) Ping" | Out-File -FilePath "c:\temp\put.txt" -Append 6 | 7 | [System.Windows.Threading.Dispatcher]::CurrentDispatcher.Invoke({ $syncHash.this.SetProgress(10)}); 8 | Start-Sleep -Seconds 2 9 | [System.Windows.Threading.Dispatcher]::CurrentDispatcher.Invoke({ $syncHash.this.SetProgress(50)}); 10 | Start-Sleep -Seconds 2 11 | [System.Windows.Threading.Dispatcher]::CurrentDispatcher.Invoke({ $syncHash.this.SetProgress(99)}); 12 | } 13 | 14 | $callback = { 15 | param($this) 16 | function w ($string) { 17 | $string | Out-File -FilePath "c:\temp\put.txt" -Append 18 | } 19 | 20 | 21 | w ($null -eq $this) 22 | 23 | $this.SetValue("2234") 24 | 25 | w "Dispatcher done" 26 | } 27 | 28 | $afterWork = 29 | { 30 | [System.Windows.Threading.Dispatcher]::CurrentDispatcher.Invoke({ 31 | function w ($string) { 32 | $string | Out-File -FilePath "c:\temp\put.txt" -Append 33 | } 34 | 35 | w ("callback $($synchash.callback)") 36 | &$syncHash.CallBack $syncHash.This 37 | }) 38 | } 39 | 40 | # main worker that builds the runspace and invokes work in it 41 | 42 | $d = -------------------------------------------------------------------------------- /q.ps1: -------------------------------------------------------------------------------- 1 | Import-Module "C:\projects\WPwshF\ObservableConcurrentQueue.dll" 2 | 3 | $queue = [System.Collections.Concurrent.ObservableConcurrentQueue[object]]::new() 4 | $e = Register-ObjectEvent -InputObject $queue -EventName ContentChanged -Action { Write-Host "new content" } 5 | 6 | $psCmd = [powershell]::Create() 7 | $syncHash = [hashtable]::Synchronized(@{}) 8 | $newRunspace =[runspacefactory]::CreateRunspace() 9 | $newRunspace.Open() 10 | $newRunspace.SessionStateProxy.SetVariable("queue",$queue) 11 | $psCmd.Runspace = $newRunspace 12 | $psCmd.AddScript({ 13 | $counter = 0 14 | While ($true) { 15 | $o = { Write-Host } 16 | Start-Sleep -Seconds 1 17 | "$(Get-Date) Adding $()" | Out-File -FilePath "c:\temp\put.txt" -Append 18 | $queue.Enqueue(++$c) 19 | "$(Get-Date) Added" | Out-File -FilePath "c:\temp\put.txt" -Append 20 | } 21 | }) 22 | $data = $psCmd.BeginInvoke() 23 | 24 | 25 | # $psCmd.Stop() -------------------------------------------------------------------------------- /refreshingBrowserViewModel.ps1: -------------------------------------------------------------------------------- 1 | 2 | [string]$xaml = @" 3 | 6 | 7 | 8 | 9 | 10 |