├── .gitignore ├── README.md ├── Roslinq.Core ├── ClassQuery.cs ├── ClassQueryData.cs ├── InheritanceHelper.cs ├── MethodQuery.cs ├── MethodQueryData.cs ├── Modifiers.cs ├── ProjectQuery.cs ├── ProjectQueryData.cs ├── Properties │ └── AssemblyInfo.cs ├── ReferencesQuery.cs ├── Roslinq.Core.GeneratedMSBuildEditorConfig.editorconfig ├── Roslinq.Core.csproj ├── SolutionQuery.cs ├── TypeComparer.cs ├── app.config └── packages.config ├── Roslinq.Tests.Integration ├── ClassTests.cs ├── MethodTests.cs ├── ProjectTests.cs ├── Properties │ └── AssemblyInfo.cs ├── Roslinq.Tests.Integration.csproj ├── SolutionTest.cs ├── app.config └── packages.config ├── Roslinq.Tests ├── ClassQueryDataTests.cs ├── CompilationTest.cs ├── InheritanceTests.cs ├── MethodQueryDataTests.cs ├── Properties │ └── AssemblyInfo.cs ├── Roslinq.Tests.csproj ├── TypeComparisonTests.cs ├── app.config └── packages.config ├── Roslinq.sln └── RoslinqTestTarget ├── AppCode └── InternalLogic.cs ├── App_Start ├── BundleConfig.cs ├── FilterConfig.cs └── RouteConfig.cs ├── Content └── Site.css ├── Controllers ├── AdminController.cs ├── AdminReportingController.cs └── HomeController.cs ├── Global.asax ├── Global.asax.cs ├── Models └── SerializableModel.cs ├── Project_Readme.html ├── Properties └── AssemblyInfo.cs ├── RoslinqTestTarget.csproj ├── Scripts ├── _references.js ├── bootstrap.js ├── bootstrap.min.js ├── jquery-1.10.2.intellisense.js ├── jquery-1.10.2.js ├── jquery-1.10.2.min.js ├── jquery-1.10.2.min.map ├── jquery.validate-vsdoc.js ├── jquery.validate.js ├── jquery.validate.min.js ├── jquery.validate.unobtrusive.js ├── jquery.validate.unobtrusive.min.js ├── modernizr-2.6.2.js ├── respond.js └── respond.min.js ├── Views ├── Home │ ├── About.cshtml │ ├── Contact.cshtml │ └── Index.cshtml ├── Shared │ ├── Error.cshtml │ └── _Layout.cshtml ├── Web.config └── _ViewStart.cshtml ├── Web.Debug.config ├── Web.Release.config ├── Web.config ├── favicon.ico └── packages.config /.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 | *.sln.docstates 8 | *.pubxml 9 | *.userosscache 10 | 11 | # User-specific files (MonoDevelop/Xamarin Studio) 12 | *.userprefs 13 | 14 | # Build results 15 | [Dd]ebug/ 16 | [Dd]ebugPublic/ 17 | [Rr]elease/ 18 | x64/ 19 | [Rr]eleases/ 20 | x86/ 21 | build/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | .vscode/ 26 | 27 | CouponFollow.Web/resources/js/alerts/**/*.js 28 | CouponFollow.Web/resources/js/alerts/**/*.js.map 29 | CouponFollow.Web/resources/js/sendout/**/*.js 30 | CouponFollow.Web/resources/js/sendout/**/*.js.map 31 | CouponFollow.Web/resources/js/common/**/*.js 32 | CouponFollow.Web/resources/js/common/**/*.js.map 33 | CouponFollow.Web/resources/js/Utils.js 34 | CouponFollow.Web/resources/js/Utils.js.map 35 | CouponFollow.Web/resources/catc_banners/catc_banners.js 36 | CouponFollow.Web/resources/catc_banners/catc_banners.js.map 37 | CouponFollow.Web/resources/js/mobile/**/*.js 38 | CouponFollow.Web/resources/js/mobile/**/*.js.map 39 | CouponFollow.Web/resources/js/desktop/**/*.js 40 | CouponFollow.Web/resources/js/desktop/**/*.js.map 41 | CouponFollow.Web/resources/js/admin/**/*.js 42 | CouponFollow.Web/resources/js/admin/**/*.js.map 43 | CouponFollow.Web/resources/checkout/ts/*.js 44 | CouponFollow.Web/resources/checkout/ts/*.js.map 45 | CouponFollow.Web/resources/js/cently/**/*.js 46 | CouponFollow.Web/resources/js/cently/**/*.js.map 47 | CouponFollow.Web/resources/js/smilematic/**/*.js 48 | CouponFollow.Web/resources/js/smilematic/**/*.js.map 49 | CouponFollow.Web/resources/js/specialOffers/**/*.js 50 | CouponFollow.Web/resources/js/specialOffers/**/*.js.map 51 | CouponFollow.Web/resources/js/mturk/**/*.js 52 | CouponFollow.Web/resources/js/mturk/**/*.js.map 53 | 54 | CouponFollow.Web/Content/cf-styles.min.css 55 | CouponFollow.Web/Scripts/cf.min.js 56 | CouponFollow.Web/Scripts/external-settings.min.js 57 | CouponFollow.Web/Scripts/plugins.min.js 58 | CouponFollow.Web/resources/alerts-management.min.js 59 | CouponFollow.Web/resources/alerts-popup.min.js 60 | CouponFollow.Web/resources/cfv3-global.min.js 61 | CouponFollow.Web/resources/cfv3-global.min.js.map 62 | CouponFollow.Web/resources/checkout/checkout.min.js 63 | CouponFollow.Web/resources/checkout/css/styles-checkout.min.css 64 | CouponFollow.Web/resources/checkout/css/styles-checkout-success.min.css 65 | CouponFollow.Web/resources/checkout/css/styles-checkout-uninstall.min.css 66 | CouponFollow.Web/resources/css/styles-alerts.min.css 67 | CouponFollow.Web/resources/css/styles-global.min.css 68 | CouponFollow.Web/resources/css/styles-popup.min.css 69 | CouponFollow.Web/resources/css/desktop/site-popup.min.css 70 | CouponFollow.Web/resources/css/desktop/site.min.css 71 | CouponFollow.Web/resources/css/desktop/layout.min.css 72 | CouponFollow.Web/resources/css/desktop/layout2.min.css 73 | CouponFollow.Web/resources/css/desktop/site2.min.css 74 | CouponFollow.Web/resources/js/desktop/bundle.min.js 75 | CouponFollow.Web/resources/js/mobile/mobile.min.js 76 | CouponFollow.Web/resources/checkout/js/checkout-success.min.js 77 | CouponFollow.Web/resources/checkout/js/checkout-uninstall.min.js 78 | CouponFollow.Web/resources/checkout/js/*.min.js.map 79 | CouponFollow.Web/resources/css/desktop/research-bundle.css 80 | CouponFollow.Web/resources/css/desktop/homepage-bundle.min.css 81 | CouponFollow.Web/resources/css/mobile/home-bundle.css 82 | CouponFollow.Web/resources/css/mobile/site-bundle.css 83 | CouponFollow.Web/resources/css/mobile/amp-site-bundle.css 84 | CouponFollow.Web/resources/css/desktop/admin.min.css 85 | CouponFollow.Web/resources/js/cently/landing.min.js 86 | CouponFollow.Web/resources/css/cently/landing.min.css 87 | CouponFollow.Web/resources/css/cently/*.min.css 88 | CouponFollow.Web/resources/css/smilematic/*.min.css 89 | CouponFollow.Web/resources/css/desktop/blog.min.css 90 | CouponFollow.Web/resources/js/desktop/*.min.js 91 | CouponFollow.Web/resources/css/desktop/*.min.css 92 | CouponFollow.Web/resources/css/mobile/*.min.css 93 | CouponFollow.Web/resources/css/specialOffers/*.min.css 94 | CouponFollow.Web/resources/css/styles-alerts-manage.min.css 95 | # Roslyn cache directories 96 | *.ide/ 97 | 98 | # Visual Studio 2015 cache/options directory 99 | .vs/ 100 | 101 | # MSTest test Results 102 | [Tt]est[Rr]esult*/ 103 | [Bb]uild[Ll]og.* 104 | 105 | # NUNIT 106 | *.VisualState.xml 107 | TestResult.xml 108 | 109 | # Build Results of an ATL Project 110 | [Dd]ebugPS/ 111 | [Rr]eleasePS/ 112 | dlldata.c 113 | 114 | # DNX 115 | project.lock.json 116 | artifacts/ 117 | 118 | *_i.c 119 | *_p.c 120 | *_i.h 121 | *.ilk 122 | *.meta 123 | *.obj 124 | *.pch 125 | *.pdb 126 | *.pgc 127 | *.pgd 128 | *.rsp 129 | *.sbr 130 | *.tlb 131 | *.tli 132 | *.tlh 133 | *.tmp 134 | *.tmp_proj 135 | *.log 136 | *.vspscc 137 | *.vssscc 138 | .builds 139 | *.pidb 140 | *.svclog 141 | *.scc 142 | 143 | # Chutzpah Test files 144 | _Chutzpah* 145 | 146 | # Visual C++ cache files 147 | ipch/ 148 | *.aps 149 | *.ncb 150 | *.opensdf 151 | *.sdf 152 | *.cachefile 153 | 154 | # Visual Studio profiler 155 | *.psess 156 | *.vsp 157 | *.vspx 158 | 159 | # TFS 2012 Local Workspace 160 | $tf/ 161 | 162 | # Guidance Automation Toolkit 163 | *.gpState 164 | 165 | # ReSharper is a .NET coding add-in 166 | _ReSharper*/ 167 | *.[Rr]e[Ss]harper 168 | *.DotSettings.user 169 | 170 | # JustCode is a .NET coding add-in 171 | .JustCode 172 | 173 | # TeamCity is a build add-in 174 | _TeamCity* 175 | 176 | # DotCover is a Code Coverage Tool 177 | *.dotCover 178 | 179 | # NCrunch 180 | _NCrunch_* 181 | .*crunch*.local.xml 182 | 183 | # MightyMoose 184 | *.mm.* 185 | AutoTest.Net/ 186 | 187 | # Web workbench (sass) 188 | .sass-cache/ 189 | 190 | # Installshield output folder 191 | [Ee]xpress/ 192 | 193 | # DocProject is a documentation generator add-in 194 | DocProject/buildhelp/ 195 | DocProject/Help/*.HxT 196 | DocProject/Help/*.HxC 197 | DocProject/Help/*.hhc 198 | DocProject/Help/*.hhk 199 | DocProject/Help/*.hhp 200 | DocProject/Help/Html2 201 | DocProject/Help/html 202 | 203 | # Click-Once directory 204 | publish/ 205 | 206 | # Publish Web Output 207 | *.[Pp]ublish.xml 208 | *.azurePubxml 209 | ## TODO: Comment the next line if you want to checkin your 210 | ## web deploy settings but do note that will include unencrypted 211 | ## passwords 212 | #*.pubxml 213 | 214 | *.publishproj 215 | 216 | # NuGet Packages 217 | *.nupkg 218 | # The packages folder can be ignored because of Package Restore 219 | **/packages/* 220 | # except build/, which is used as an MSBuild target. 221 | !**/packages/build/ 222 | # Uncomment if necessary however generally it will be regenerated when needed 223 | #!**/packages/repositories.config 224 | 225 | # Windows Azure Build Output 226 | csx/ 227 | *.build.csdef 228 | 229 | # Windows Store app package directory 230 | AppPackages/ 231 | 232 | 233 | # Visual Studio cache files 234 | # files ending in .cache can be ignored 235 | *.[Cc]ache 236 | # but keep track of directories ending in .cache 237 | !*.[Cc]ache/ 238 | 239 | # Others 240 | ClientBin/ 241 | [Ss]tyle[Cc]op.* 242 | !stylecop.ruleset 243 | ~$* 244 | *~ 245 | *.dbmdl 246 | *.dbproj.schemaview 247 | *.pfx 248 | *.publishsettings 249 | node_modules/ 250 | sql/ 251 | *.Cache 252 | orleans.codegen.cs 253 | 254 | # RIA/Silverlight projects 255 | Generated_Code/ 256 | 257 | # Backup & report files from converting an old project file 258 | # to a newer Visual Studio version. Backup files are not needed, 259 | # because we have git ;-) 260 | _UpgradeReport_Files/ 261 | Backup*/ 262 | !CFApps.BackupApp 263 | UpgradeLog*.XML 264 | UpgradeLog*.htm 265 | 266 | # SQL Server files 267 | *.mdf 268 | *.ldf 269 | 270 | # Business Intelligence projects 271 | *.rdl.data 272 | *.bim.layout 273 | *.bim_*.settings 274 | 275 | # Microsoft Fakes 276 | FakesAssemblies/ 277 | 278 | # Node.js Tools for Visual Studio 279 | .ntvs_analysis.dat 280 | 281 | # Visual Studio 6 build log 282 | *.plg 283 | 284 | # Visual Studio 6 workspace options file 285 | *.opt 286 | 287 | # LightSwitch generated files 288 | GeneratedArtifacts/ 289 | _Pvt_Extensions/ 290 | ModelManifest.xml 291 | 292 | secure.config 293 | robots.txt 294 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Roslinq (LINQ to Roslyn) 2 | Roslinq is a Roslyn based component that enables queries over C# source code. 3 | 4 | ## Features 5 | Roslinq currently supports: 6 | 7 | * MSBuild based workspaces (_.sln_, _.csproj_) 8 | * class queries 9 | * method queries 10 | 11 | ## Examples 12 | 13 | Private static methods taking `int` parameter input: 14 | 15 | ``` csharp 16 | var codeQuery = new ProjectQuery(@"path\to\RoslinqTestTarget.csproj"); 17 | var result = codeQuery 18 | .Classes 19 | .Methods 20 | .WithModifier(MethodModifier.Static) 21 | .WithModifier(MethodModifier.Private) 22 | .WithParameterType() 23 | .Execute(); 24 | ``` 25 | 26 | HTTP POST handlers in MVC Controllers: 27 | 28 | ``` csharp 29 | var codeQuery = new ProjectQuery(@"path\to\RoslinqTestTarget.csproj"); 30 | var postControllerActions = codeQuery 31 | .Classes.InheritingFrom() 32 | .Methods.WithAttribute() 33 | .Execute(); 34 | ``` 35 | -------------------------------------------------------------------------------- /Roslinq.Core/ClassQuery.cs: -------------------------------------------------------------------------------- 1 | namespace Roslinq 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | public class ClassQuery 8 | { 9 | private IList classes; 10 | 11 | internal ClassQuery(IList classes) 12 | { 13 | this.classes = classes; 14 | } 15 | 16 | /// 17 | /// Entry point for creating and executing method queries. 18 | /// 19 | public MethodQuery Methods 20 | { 21 | get 22 | { 23 | return new MethodQuery(GetMethods().ToList()); 24 | } 25 | } 26 | 27 | private IEnumerable GetMethods() 28 | { 29 | foreach (var @class in this.classes) 30 | { 31 | foreach (var methodSymbol in @class.Methods) 32 | { 33 | yield return new MethodQueryData(methodSymbol); 34 | } 35 | } 36 | } 37 | 38 | /// 39 | /// Executes the query with all previously applied filters. 40 | /// 41 | /// The list of 42 | public IList Execute() 43 | { 44 | return this.classes; 45 | } 46 | 47 | /// 48 | /// Filter classes by type they inherit from (directly or indirectly). 49 | /// 50 | /// The type that class inherits from. 51 | public ClassQuery InheritingFrom(Type type) 52 | { 53 | this.Filter(x => x.InheritsFrom(type)); 54 | return this; 55 | } 56 | 57 | /// 58 | /// Filter classes by type they inherit from (directly or indirectly). 59 | /// 60 | /// The type that class inherits from. 61 | public ClassQuery InheritingFrom() 62 | { 63 | return this.InheritingFrom(typeof(T)); 64 | } 65 | 66 | /// 67 | /// Filter classes by interface they implement. 68 | /// 69 | /// Type of the interface. 70 | /// If the type is not interface type. 71 | public ClassQuery ImplementingInterface(Type interfaceType) 72 | { 73 | if (!interfaceType.IsInterface) 74 | { 75 | throw new ArgumentException("Only interface types allowed", "interfaceType"); 76 | } 77 | 78 | this.Filter(x => x.ImplementsInterface(interfaceType)); 79 | return this; 80 | } 81 | 82 | /// 83 | /// Filter classes by interface they implement. 84 | /// 85 | /// Type of the interface. 86 | /// If the type is not interface type. 87 | public ClassQuery ImplementingInterface() 88 | { 89 | return this.ImplementingInterface(typeof(T)); 90 | } 91 | 92 | /// 93 | /// Filter classes by attribute thay have applied. 94 | /// 95 | /// Attribute type. 96 | /// If the type is not attribute type. 97 | public ClassQuery WithAttribute(Type type) 98 | { 99 | if (!InheritanceHelper.InheritsFrom(type, typeof(Attribute))) 100 | { 101 | throw new ArgumentException("Only attribute types allowed", "type"); 102 | } 103 | 104 | this.Filter(x => x.HasAttributeApplied(type)); 105 | return this; 106 | } 107 | 108 | /// 109 | /// Filter classes by attribute thay have applied. 110 | /// 111 | /// Attribute type. 112 | /// If the type is not attribute type. 113 | public ClassQuery WithAttribute() 114 | { 115 | return this.WithAttribute(typeof(T)); 116 | } 117 | 118 | /// 119 | /// Filter classes by modifier they have applied. 120 | /// 121 | /// access modifier. 122 | public ClassQuery WithModifier(ClassModifier modifier) 123 | { 124 | this.Filter(x => x.HasModifier(modifier)); 125 | return this; 126 | } 127 | 128 | private void Filter(Func predicate) 129 | { 130 | var result = this.classes.Where(predicate).ToList(); 131 | this.classes = result; 132 | } 133 | } 134 | } -------------------------------------------------------------------------------- /Roslinq.Core/ClassQueryData.cs: -------------------------------------------------------------------------------- 1 | namespace Roslinq 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using Microsoft.CodeAnalysis; 7 | 8 | public class ClassQueryData 9 | { 10 | private readonly INamedTypeSymbol classSymbol; 11 | 12 | internal ClassQueryData(INamedTypeSymbol clasSymbol) 13 | { 14 | this.classSymbol = clasSymbol; 15 | } 16 | 17 | public string ClassName 18 | { 19 | get { return this.classSymbol.ToString(); } 20 | } 21 | 22 | internal bool InheritsFrom(Type type) 23 | { 24 | return InheritanceHelper.InheritsFrom(this.classSymbol, type); 25 | } 26 | 27 | internal IEnumerable Methods 28 | { 29 | get 30 | { 31 | return classSymbol.GetMembers().Where(m => m.Kind == SymbolKind.Method).Cast(); 32 | } 33 | } 34 | 35 | internal bool ImplementsInterface(Type interfaceType) 36 | { 37 | if (this.classSymbol.Interfaces == null) 38 | { 39 | return false; 40 | } 41 | 42 | if (!this.classSymbol.Interfaces.Any()) 43 | { 44 | return false; 45 | } 46 | 47 | if (this.classSymbol.Interfaces.FirstOrDefault(i => TypeComparer.TypesMatch(i, interfaceType)) != null) 48 | { 49 | return true; 50 | } 51 | 52 | return false; 53 | } 54 | 55 | internal bool HasAttributeApplied(Type type) 56 | { 57 | var classAppliedAttributes = this.classSymbol.GetAttributes(); 58 | foreach (var methodAppliedAttribute in classAppliedAttributes) 59 | { 60 | if (TypeComparer.TypesMatch(methodAppliedAttribute.AttributeClass, type)) 61 | { 62 | return true; 63 | } 64 | } 65 | 66 | return false; 67 | } 68 | 69 | internal bool HasModifier(ClassModifier modifier) 70 | { 71 | switch (modifier) 72 | { 73 | case ClassModifier.Private: 74 | return this.classSymbol.DeclaredAccessibility == Accessibility.Private; 75 | case ClassModifier.Protected: 76 | return this.classSymbol.DeclaredAccessibility == Accessibility.Protected; 77 | case ClassModifier.Public: 78 | return this.classSymbol.DeclaredAccessibility == Accessibility.Public; 79 | case ClassModifier.Internal: 80 | return this.classSymbol.DeclaredAccessibility == Accessibility.Internal; 81 | case ClassModifier.Static: 82 | return this.classSymbol.IsStatic; 83 | case ClassModifier.Sealed: 84 | return this.classSymbol.IsSealed; 85 | case ClassModifier.Abstract: 86 | return this.classSymbol.IsAbstract; 87 | default: throw new NotImplementedException(string.Format("Modifier {0} is unknown", modifier)); 88 | } 89 | } 90 | } 91 | } -------------------------------------------------------------------------------- /Roslinq.Core/InheritanceHelper.cs: -------------------------------------------------------------------------------- 1 | namespace Roslinq 2 | { 3 | using System; 4 | using Microsoft.CodeAnalysis; 5 | 6 | internal class InheritanceHelper 7 | { 8 | /// 9 | /// Check if a given type directly or indirectly iherits from other type. 10 | /// 11 | /// Type which base type is being checked 12 | /// Type which is potentially a base type 13 | /// True if queried type inherits from type, false otherwise. 14 | internal static bool InheritsFrom(Type queriedType, Type type) 15 | { 16 | if (queriedType.BaseType == null) 17 | { 18 | return false; 19 | } 20 | 21 | if (queriedType.BaseType == type) 22 | { 23 | return true; 24 | } 25 | 26 | if (queriedType.BaseType.Name == typeof(object).Name) 27 | { 28 | return false; 29 | } 30 | 31 | return InheritsFrom(queriedType.BaseType, type); 32 | } 33 | 34 | /// 35 | /// Check if a given type directly or indirectly iherits from other type. 36 | /// 37 | /// Type which base type is being checked 38 | /// Type which is potentially a base type 39 | /// True if queried type inherits from type, false otherwise. 40 | internal static bool InheritsFrom(INamedTypeSymbol queriedType, Type type) 41 | { 42 | var classBaseType = queriedType.BaseType; 43 | if (classBaseType == null) 44 | { 45 | return false; 46 | } 47 | 48 | if (TypeComparer.TypesMatch(classBaseType, type)) 49 | { 50 | return true; 51 | } 52 | 53 | if (TypeComparer.TypesMatch(classBaseType, typeof(object))) 54 | { 55 | return false; 56 | } 57 | 58 | return InheritsFrom(classBaseType, type); 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /Roslinq.Core/MethodQuery.cs: -------------------------------------------------------------------------------- 1 | namespace Roslinq 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | public class MethodQuery 8 | { 9 | private IList methods; 10 | 11 | internal MethodQuery(IList methods) 12 | { 13 | this.methods = methods; 14 | } 15 | 16 | /// 17 | /// Executes the query with all previously applied filters. 18 | /// 19 | /// The list of 20 | public IList Execute() 21 | { 22 | return this.methods; 23 | } 24 | 25 | /// 26 | /// Filter methods by type they return. 27 | /// 28 | /// The type of value that method returns. 29 | public MethodQuery ReturningType(Type type) 30 | { 31 | Filter(x => x.ReturnsType(type)); 32 | return this; 33 | } 34 | 35 | /// 36 | /// Filter methods by type they return. 37 | /// 38 | /// The type of value that method returns. 39 | public MethodQuery ReturningType() 40 | { 41 | return this.ReturningType(typeof(T)); 42 | } 43 | 44 | /// 45 | /// Filter methods by parameter type they take. 46 | /// 47 | /// The type of paramter that method takes. 48 | public MethodQuery WithParameterType(Type parameterType) 49 | { 50 | this.Filter(x => x.HasParameterType(parameterType)); 51 | return this; 52 | } 53 | 54 | /// 55 | /// Filter methods by parameter type they take. 56 | /// 57 | /// The type of paramter that method takes. 58 | public MethodQuery WithParameterType() 59 | { 60 | return this.WithParameterType(typeof(T)); 61 | } 62 | 63 | /// 64 | /// Filter methods by modifier they have applied. 65 | /// 66 | /// access modifier. 67 | /// 68 | public MethodQuery WithModifier(MethodModifier modifier) 69 | { 70 | this.Filter(x => x.HasModifier(modifier)); 71 | return this; 72 | } 73 | 74 | private void Filter(Func predicate) 75 | { 76 | var result = this.methods.Where(predicate).ToList(); 77 | this.methods = result; 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /Roslinq.Core/MethodQueryData.cs: -------------------------------------------------------------------------------- 1 | namespace Roslinq 2 | { 3 | using System; 4 | using System.Linq; 5 | using Microsoft.CodeAnalysis; 6 | 7 | public class MethodQueryData 8 | { 9 | private readonly IMethodSymbol methodSymbol; 10 | 11 | internal MethodQueryData(IMethodSymbol methodSymbol) 12 | { 13 | this.methodSymbol = methodSymbol; 14 | } 15 | 16 | public string MethodName 17 | { 18 | get { return this.methodSymbol.Name; } 19 | } 20 | 21 | internal bool ReturnsType(Type type) 22 | { 23 | return TypeComparer.TypesMatch(this.methodSymbol.ReturnType, type); 24 | } 25 | 26 | internal bool HasAttributeApplied(Type type) 27 | { 28 | var methodAppliedAttributes = this.methodSymbol.GetAttributes(); 29 | foreach (var methodAppliedAttribute in methodAppliedAttributes) 30 | { 31 | if (TypeComparer.TypesMatch(methodAppliedAttribute.AttributeClass, type)) 32 | { 33 | return true; 34 | } 35 | } 36 | 37 | return false; 38 | } 39 | 40 | internal bool HasParameterType(Type parameterType) 41 | { 42 | if (!this.methodSymbol.Parameters.Any()) 43 | { 44 | return false; 45 | } 46 | 47 | foreach (var parameter in this.methodSymbol.Parameters) 48 | { 49 | if (TypeComparer.TypesMatch(parameter.Type, parameterType)) 50 | { 51 | return true; 52 | } 53 | 54 | if (parameter.IsParams) 55 | { 56 | var arrayType = (IArrayTypeSymbol)parameter.Type; 57 | if (TypeComparer.TypesMatch(arrayType.ElementType, parameterType)) 58 | { 59 | return true; 60 | } 61 | } 62 | } 63 | 64 | return false; 65 | } 66 | 67 | internal bool HasModifier(MethodModifier modifier) 68 | { 69 | switch (modifier) 70 | { 71 | case MethodModifier.Private: 72 | return this.methodSymbol.DeclaredAccessibility == Accessibility.Private; 73 | case MethodModifier.Protected: 74 | return this.methodSymbol.DeclaredAccessibility == Accessibility.Protected; 75 | case MethodModifier.Public: 76 | return this.methodSymbol.DeclaredAccessibility == Accessibility.Public; 77 | case MethodModifier.Internal: 78 | return this.methodSymbol.DeclaredAccessibility == Accessibility.Internal; 79 | case MethodModifier.Static: 80 | return this.methodSymbol.IsStatic; 81 | case MethodModifier.Virtual: 82 | return this.methodSymbol.IsVirtual; 83 | case MethodModifier.Abstract: 84 | return this.methodSymbol.IsAbstract; 85 | default: throw new NotImplementedException(string.Format("Modifier {0} is unknown", modifier)); 86 | } 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /Roslinq.Core/Modifiers.cs: -------------------------------------------------------------------------------- 1 | namespace Roslinq 2 | { 3 | /// 4 | /// Class modifiers constants. 5 | /// 6 | public enum ClassModifier 7 | { 8 | Public = 1, 9 | Protected = 2, 10 | Private = 3, 11 | Internal = 4, 12 | Static = 5, 13 | Sealed = 6, 14 | Abstract = 7 15 | } 16 | 17 | /// 18 | /// Method modifiers constants. 19 | /// 20 | public enum MethodModifier 21 | { 22 | Public = 1, 23 | Protected = 2, 24 | Private = 3, 25 | Internal = 4, 26 | Static = 5, 27 | Abstract = 7, 28 | Virtual = 8 29 | } 30 | } -------------------------------------------------------------------------------- /Roslinq.Core/ProjectQuery.cs: -------------------------------------------------------------------------------- 1 | namespace Roslinq 2 | { 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using Microsoft.Build.Locator; 6 | using Microsoft.CodeAnalysis.MSBuild; 7 | 8 | public class ProjectQuery 9 | { 10 | private readonly IList projects; 11 | 12 | internal ProjectQuery(IList projects) 13 | { 14 | this.projects = projects; 15 | } 16 | 17 | /// 18 | /// Creates new instance of ProjectQuery based on a project stored in given location on disk. 19 | /// 20 | /// Full path to project location on disk. 21 | public ProjectQuery(string projectPath) 22 | { 23 | MSBuildLocator.RegisterDefaults(); 24 | MSBuildWorkspace workspace = MSBuildWorkspace.Create(); 25 | this.projects = new List {new ProjectQueryData(workspace.OpenProjectAsync(projectPath).Result)}; 26 | } 27 | 28 | /// 29 | /// Executes the query with all previously applied filters. 30 | /// 31 | /// The list of 32 | public IList Execute() 33 | { 34 | return this.projects; 35 | } 36 | 37 | /// 38 | /// Entry point for creating and executing class queries. 39 | /// 40 | public ClassQuery Classes 41 | { 42 | get 43 | { 44 | return new ClassQuery(GetClasses().ToList()); 45 | } 46 | } 47 | 48 | private IEnumerable GetClasses() 49 | { 50 | 51 | foreach (var p in this.projects) 52 | { 53 | foreach (var namedTypeSymbol in p.Classes) 54 | { 55 | yield return new ClassQueryData(namedTypeSymbol); 56 | } 57 | } 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /Roslinq.Core/ProjectQueryData.cs: -------------------------------------------------------------------------------- 1 | namespace Roslinq 2 | { 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using Microsoft.CodeAnalysis; 6 | using Microsoft.CodeAnalysis.CSharp.Syntax; 7 | 8 | public class ProjectQueryData 9 | { 10 | private readonly Project project; 11 | 12 | public ProjectQueryData(Project project) 13 | { 14 | this.project = project; 15 | } 16 | 17 | public string ProjectName 18 | { 19 | get { return this.project.Name; } 20 | } 21 | 22 | internal IEnumerable Classes 23 | { 24 | get 25 | { 26 | foreach (var document in this.project.Documents) 27 | { 28 | var model = document.GetSemanticModelAsync().Result; 29 | var syntaxTree = model.SyntaxTree; 30 | var classSyntaxNodes = syntaxTree.GetRoot().DescendantNodes().OfType(); 31 | foreach (var classSyntaxNode in classSyntaxNodes) 32 | { 33 | var classSymbol = (INamedTypeSymbol)model.GetDeclaredSymbol(classSyntaxNode); 34 | yield return classSymbol; 35 | } 36 | } 37 | } 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Roslinq.Core/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Roslinq.Core")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Roslinq.Core")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2ce1f7fd-852f-495f-9f45-49a2bedf2346")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | [assembly: InternalsVisibleTo("Roslinq.Tests")] -------------------------------------------------------------------------------- /Roslinq.Core/ReferencesQuery.cs: -------------------------------------------------------------------------------- 1 | namespace Roslinq 2 | { 3 | public class ReferencesQuery 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /Roslinq.Core/Roslinq.Core.GeneratedMSBuildEditorConfig.editorconfig: -------------------------------------------------------------------------------- 1 | is_global = true 2 | build_property.TargetFramework = 3 | build_property.TargetPlatformMinVersion = 4 | build_property.UsingMicrosoftNETSdkWeb = 5 | build_property.ProjectTypeGuids = 6 | build_property.PublishSingleFile = 7 | build_property.IncludeAllContentForSelfExtract = 8 | build_property._SupportedPlatformList = 9 | -------------------------------------------------------------------------------- /Roslinq.Core/Roslinq.Core.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Debug 7 | AnyCPU 8 | {2CE1F7FD-852F-495F-9F45-49A2BEDF2346} 9 | Library 10 | Properties 11 | Roslinq 12 | Roslinq 13 | v4.7.2 14 | 512 15 | 16 | 17 | 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | bin\Debug\Roslinq.xml 28 | 29 | 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | ..\packages\Humanizer.Core.2.8.26\lib\netstandard2.0\Humanizer.dll 40 | 41 | 42 | ..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll 43 | 44 | 45 | ..\packages\Microsoft.Build.Framework.16.8.0\lib\net472\Microsoft.Build.Framework.dll 46 | 47 | 48 | ..\packages\Microsoft.Build.Locator.1.4.1\lib\net46\Microsoft.Build.Locator.dll 49 | 50 | 51 | ..\packages\Microsoft.Build.Tasks.Core.16.8.0\lib\net472\Microsoft.Build.Tasks.Core.dll 52 | 53 | 54 | ..\packages\Microsoft.Build.Utilities.Core.16.8.0\lib\net472\Microsoft.Build.Utilities.Core.dll 55 | 56 | 57 | ..\packages\Microsoft.CodeAnalysis.Common.3.8.0\lib\netstandard2.0\Microsoft.CodeAnalysis.dll 58 | 59 | 60 | ..\packages\Microsoft.CodeAnalysis.CSharp.3.8.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll 61 | 62 | 63 | ..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.3.8.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Workspaces.dll 64 | 65 | 66 | ..\packages\Microsoft.CodeAnalysis.VisualBasic.3.8.0\lib\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.dll 67 | 68 | 69 | ..\packages\Microsoft.CodeAnalysis.VisualBasic.Workspaces.3.8.0\lib\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll 70 | 71 | 72 | ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.3.8.0\lib\netstandard2.0\Microsoft.CodeAnalysis.Workspaces.dll 73 | 74 | 75 | ..\packages\Microsoft.CodeAnalysis.Workspaces.MSBuild.3.8.0\lib\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll 76 | 77 | 78 | ..\packages\Microsoft.VisualStudio.Setup.Configuration.Interop.1.16.30\lib\net35\Microsoft.VisualStudio.Setup.Configuration.Interop.dll 79 | True 80 | 81 | 82 | 83 | ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll 84 | 85 | 86 | ..\packages\System.Collections.Immutable.5.0.0\lib\net461\System.Collections.Immutable.dll 87 | 88 | 89 | 90 | ..\packages\System.Composition.AttributedModel.5.0.1\lib\net461\System.Composition.AttributedModel.dll 91 | 92 | 93 | ..\packages\System.Composition.Convention.5.0.1\lib\net461\System.Composition.Convention.dll 94 | 95 | 96 | ..\packages\System.Composition.Hosting.5.0.1\lib\net461\System.Composition.Hosting.dll 97 | 98 | 99 | ..\packages\System.Composition.Runtime.5.0.1\lib\net461\System.Composition.Runtime.dll 100 | 101 | 102 | ..\packages\System.Composition.TypedParts.5.0.1\lib\net461\System.Composition.TypedParts.dll 103 | 104 | 105 | 106 | 107 | 108 | ..\packages\System.Linq.4.3.0\lib\net463\System.Linq.dll 109 | True 110 | True 111 | 112 | 113 | ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll 114 | 115 | 116 | 117 | ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll 118 | 119 | 120 | ..\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll 121 | True 122 | True 123 | 124 | 125 | ..\packages\System.Reflection.Metadata.5.0.0\lib\net461\System.Reflection.Metadata.dll 126 | 127 | 128 | ..\packages\System.Resources.Extensions.4.6.0\lib\netstandard2.0\System.Resources.Extensions.dll 129 | 130 | 131 | ..\packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll 132 | True 133 | True 134 | 135 | 136 | ..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll 137 | 138 | 139 | ..\packages\System.Runtime.Extensions.4.3.1\lib\net462\System.Runtime.Extensions.dll 140 | True 141 | True 142 | 143 | 144 | ..\packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll 145 | True 146 | True 147 | 148 | 149 | 150 | 151 | 152 | ..\packages\System.Text.Encoding.CodePages.5.0.0\lib\net461\System.Text.Encoding.CodePages.dll 153 | 154 | 155 | ..\packages\System.Threading.Tasks.Dataflow.5.0.0\lib\net461\System.Threading.Tasks.Dataflow.dll 156 | 157 | 158 | ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll 159 | 160 | 161 | ..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll 162 | True 163 | True 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 215 | -------------------------------------------------------------------------------- /Roslinq.Core/SolutionQuery.cs: -------------------------------------------------------------------------------- 1 | namespace Roslinq 2 | { 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using Microsoft.CodeAnalysis; 6 | using Microsoft.CodeAnalysis.CSharp.Syntax; 7 | using Microsoft.CodeAnalysis.MSBuild; 8 | 9 | public class SolutionQuery 10 | { 11 | private readonly Solution solution; 12 | public SolutionQuery(string solutionPath) 13 | { 14 | MSBuildWorkspace workspace = MSBuildWorkspace.Create(); 15 | this.solution = workspace.OpenSolutionAsync(solutionPath).Result; 16 | } 17 | 18 | /// 19 | /// Entry point for creating and executing project queries. 20 | /// 21 | public ProjectQuery Projects 22 | { 23 | get 24 | { 25 | return new ProjectQuery(GetProjects().ToList()); 26 | } 27 | } 28 | 29 | /// 30 | /// Entry point for creating and executing class queries. 31 | /// 32 | /// Queries over all project classes that are part of the solution. 33 | public ClassQuery Classes 34 | { 35 | get 36 | { 37 | return new ClassQuery(GetClasses().ToList()); 38 | } 39 | } 40 | 41 | private IEnumerable GetProjects() 42 | { 43 | foreach (var project in this.solution.Projects) 44 | { 45 | yield return new ProjectQueryData(project); 46 | } 47 | } 48 | 49 | private IEnumerable GetClasses() 50 | { 51 | foreach (var namedTypeSymbol in GetClassSymbols()) 52 | { 53 | yield return new ClassQueryData(namedTypeSymbol); 54 | } 55 | } 56 | 57 | private IEnumerable GetClassSymbols() 58 | { 59 | foreach (var project in this.solution.Projects) 60 | { 61 | foreach (var document in project.Documents) 62 | { 63 | var model = document.GetSemanticModelAsync().Result; 64 | var syntaxTree = model.SyntaxTree; 65 | var classSyntaxNodes = syntaxTree.GetRoot().DescendantNodes().OfType(); 66 | foreach (var classSyntaxNode in classSyntaxNodes) 67 | { 68 | var classSymbol = (INamedTypeSymbol)model.GetDeclaredSymbol(classSyntaxNode); 69 | yield return classSymbol; 70 | } 71 | } 72 | } 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /Roslinq.Core/TypeComparer.cs: -------------------------------------------------------------------------------- 1 | namespace Roslinq 2 | { 3 | using System; 4 | using Microsoft.CodeAnalysis; 5 | 6 | internal class TypeComparer 7 | { 8 | internal static bool TypesMatch(ITypeSymbol typeSymbol, Type type) 9 | { 10 | if (typeSymbol.ContainingNamespace != null) 11 | { 12 | return typeSymbol.ContainingNamespace.ToString() == type.Namespace && typeSymbol.Name == type.Name; 13 | } 14 | 15 | return typeSymbol.Name == type.Name; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Roslinq.Core/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Roslinq.Core/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /Roslinq.Tests.Integration/ClassTests.cs: -------------------------------------------------------------------------------- 1 | namespace Roslinq.Tests.Integration 2 | { 3 | using System; 4 | using System.Linq; 5 | using System.Web.Mvc; 6 | using NUnit.Framework; 7 | 8 | [TestFixture] 9 | public class ClassTests 10 | { 11 | private ProjectQuery codeQuery; 12 | [TestFixtureSetUp] 13 | public void SetUp() 14 | { 15 | this.codeQuery = new ProjectQuery(@"..\..\..\RoslinqTestTarget\RoslinqTestTarget.csproj"); 16 | } 17 | 18 | [Test] 19 | public void DirectClassInheritanceShouldBeRecognized() 20 | { 21 | var controllers = codeQuery.Classes.InheritingFrom(typeof(Controller)).Execute(); 22 | Assert.IsNotNull(controllers); 23 | Assert.IsTrue(controllers.Any()); 24 | Assert.IsNotNull(controllers.FirstOrDefault(x => x.ClassName == "RoslinqTestTarget.Controllers.HomeController")); 25 | } 26 | 27 | [Test] 28 | public void IndirectClassInheritanceShouldBeRecognized() 29 | { 30 | var controllers = codeQuery.Classes.InheritingFrom(typeof(Controller)).Execute(); 31 | Assert.IsNotNull(controllers); 32 | Assert.IsTrue(controllers.Any()); 33 | Assert.IsNotNull(controllers.FirstOrDefault(x => x.ClassName == "RoslinqTestTarget.Controllers.AdminReportingController")); 34 | } 35 | 36 | [Test] 37 | public void QueryClassesShouldReturnAllClasses() 38 | { 39 | var classes = codeQuery.Classes.Execute(); 40 | Assert.IsNotNull(classes); 41 | Assert.IsTrue(classes.Any()); 42 | } 43 | 44 | [Test] 45 | public void QueryClassesShouldReturnClassImplementingInterface() 46 | { 47 | var classes = codeQuery.Classes.ImplementingInterface(typeof(IController)).Execute(); 48 | Assert.IsNotNull(classes); 49 | Assert.IsTrue(classes.Any()); 50 | Assert.IsNotNull(classes.FirstOrDefault(x => x.ClassName == "RoslinqTestTarget.Controllers.AdminController")); 51 | } 52 | 53 | [Test] 54 | public void QueryClassesShouldReturnClassWithAttributeApplied() 55 | { 56 | var classes = codeQuery.Classes.WithAttribute(typeof(SerializableAttribute)).Execute(); 57 | Assert.IsNotNull(classes); 58 | Assert.IsTrue(classes.Any()); 59 | Assert.IsNotNull(classes.FirstOrDefault(x => x.ClassName == "RoslinqTestTarget.Models.SerializableModel")); 60 | } 61 | 62 | [Test] 63 | public void QueryClassesShouldReturnClassWithInternalModifier() 64 | { 65 | var classes = codeQuery.Classes.WithModifier(ClassModifier.Internal).Execute(); 66 | Assert.IsNotNull(classes); 67 | Assert.IsTrue(classes.Any()); 68 | Assert.IsNotNull(classes.FirstOrDefault(x => x.ClassName == "RoslinqTestTarget.AppCode.InternalLogic")); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Roslinq.Tests.Integration/MethodTests.cs: -------------------------------------------------------------------------------- 1 | namespace Roslinq.Tests.Integration 2 | { 3 | using System.Linq; 4 | using System.Web.Mvc; 5 | using NUnit.Framework; 6 | using RoslinqTestTarget.Models; 7 | 8 | [TestFixture] 9 | public class MethodTests 10 | { 11 | private ProjectQuery codeQuery; 12 | [TestFixtureSetUp] 13 | public void SetUp() 14 | { 15 | this.codeQuery = new ProjectQuery(@"..\..\..\RoslinqTestTarget\RoslinqTestTarget.csproj"); 16 | } 17 | 18 | [Test] 19 | public void ContactMethodFromHomeControllerShouldBeRecognized() 20 | { 21 | var methods = codeQuery.Classes.Methods.Execute(); 22 | Assert.IsNotNull(methods); 23 | Assert.IsTrue(methods.Any()); 24 | Assert.IsNotNull(methods.FirstOrDefault(x => x.MethodName == "About")); 25 | } 26 | 27 | [Test] 28 | public void MethodReturningPartialFromHomeControllerShouldBeRecognized() 29 | { 30 | var methods = codeQuery.Classes.Methods.ReturningType(typeof(PartialViewResult)).Execute(); 31 | Assert.IsNotNull(methods); 32 | Assert.IsTrue(methods.Any()); 33 | Assert.IsNotNull(methods.FirstOrDefault(x => x.MethodName == "Partial")); 34 | } 35 | 36 | [Test] 37 | public void MethodWithModelInputParamShouldBeRecognized() 38 | { 39 | var methods = codeQuery.Classes.Methods.WithParameterType(typeof(SerializableModel)).Execute(); 40 | Assert.IsNotNull(methods); 41 | Assert.IsTrue(methods.Any()); 42 | Assert.IsNotNull(methods.FirstOrDefault(x => x.MethodName == "Baz")); 43 | } 44 | 45 | [Test] 46 | public void PrivateStaticMethodShouldBeFound() 47 | { 48 | var methods = codeQuery.Classes.Methods 49 | .WithModifier(MethodModifier.Static) 50 | .WithModifier(MethodModifier.Private) 51 | .Execute(); 52 | Assert.IsNotNull(methods); 53 | Assert.AreEqual(1, methods.Count()); 54 | Assert.IsNotNull(methods.FirstOrDefault(x => x.MethodName == "MethodB")); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Roslinq.Tests.Integration/ProjectTests.cs: -------------------------------------------------------------------------------- 1 | namespace Roslinq.Tests.Integration 2 | { 3 | using NUnit.Framework; 4 | 5 | [TestFixture] 6 | public class ProjectTests 7 | { 8 | [Test] 9 | public void ManyClassesShouldBePresentTest() 10 | { 11 | var codeQuery = new ProjectQuery(@"..\..\..\RoslinqTestTarget\RoslinqTestTarget.csproj"); 12 | var classes = codeQuery.Classes.Execute(); 13 | Assert.IsNotNull(classes); 14 | Assert.IsTrue(classes.Count > 2); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Roslinq.Tests.Integration/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Roslinq.Tests.Integration")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Roslinq.Tests.Integration")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("1cb097a6-7425-40c8-a13d-8346ed1291eb")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Roslinq.Tests.Integration/Roslinq.Tests.Integration.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Debug 7 | AnyCPU 8 | {1CB097A6-7425-40C8-A13D-8346ED1291EB} 9 | Library 10 | Properties 11 | Roslinq.Tests.Integration 12 | Roslinq.Tests.Integration 13 | v4.7.2 14 | 512 15 | 16 | 17 | 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | ..\packages\Humanizer.Core.2.8.26\lib\netstandard2.0\Humanizer.dll 39 | 40 | 41 | ..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll 42 | 43 | 44 | ..\packages\Microsoft.CodeAnalysis.Common.3.8.0\lib\netstandard2.0\Microsoft.CodeAnalysis.dll 45 | 46 | 47 | ..\packages\Microsoft.CodeAnalysis.CSharp.3.8.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll 48 | 49 | 50 | ..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.3.8.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Workspaces.dll 51 | 52 | 53 | ..\packages\Microsoft.CodeAnalysis.VisualBasic.3.8.0\lib\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.dll 54 | 55 | 56 | ..\packages\Microsoft.CodeAnalysis.VisualBasic.Workspaces.3.8.0\lib\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll 57 | 58 | 59 | ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.3.8.0\lib\netstandard2.0\Microsoft.CodeAnalysis.Workspaces.dll 60 | 61 | 62 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 63 | True 64 | 65 | 66 | ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.dll 67 | True 68 | 69 | 70 | ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.interfaces.dll 71 | True 72 | 73 | 74 | ..\packages\NUnit.2.6.4\lib\nunit.framework.dll 75 | True 76 | 77 | 78 | ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.util.dll 79 | True 80 | 81 | 82 | ..\packages\NUnitTestAdapter.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll 83 | True 84 | 85 | 86 | 87 | ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll 88 | 89 | 90 | ..\packages\System.Collections.Immutable.5.0.0\lib\net461\System.Collections.Immutable.dll 91 | 92 | 93 | 94 | ..\packages\System.Composition.AttributedModel.5.0.1\lib\net461\System.Composition.AttributedModel.dll 95 | 96 | 97 | ..\packages\System.Composition.Convention.5.0.1\lib\net461\System.Composition.Convention.dll 98 | 99 | 100 | ..\packages\System.Composition.Hosting.5.0.1\lib\net461\System.Composition.Hosting.dll 101 | 102 | 103 | ..\packages\System.Composition.Runtime.5.0.1\lib\net461\System.Composition.Runtime.dll 104 | 105 | 106 | ..\packages\System.Composition.TypedParts.5.0.1\lib\net461\System.Composition.TypedParts.dll 107 | 108 | 109 | 110 | ..\packages\System.Linq.4.3.0\lib\net463\System.Linq.dll 111 | True 112 | True 113 | 114 | 115 | ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll 116 | 117 | 118 | 119 | ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll 120 | 121 | 122 | ..\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll 123 | True 124 | True 125 | 126 | 127 | ..\packages\System.Reflection.Metadata.5.0.0\lib\net461\System.Reflection.Metadata.dll 128 | 129 | 130 | ..\packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll 131 | True 132 | True 133 | 134 | 135 | ..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll 136 | 137 | 138 | ..\packages\System.Runtime.Extensions.4.3.1\lib\net462\System.Runtime.Extensions.dll 139 | True 140 | True 141 | 142 | 143 | ..\packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll 144 | True 145 | True 146 | 147 | 148 | ..\packages\System.Text.Encoding.CodePages.5.0.0\lib\net461\System.Text.Encoding.CodePages.dll 149 | 150 | 151 | ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll 152 | 153 | 154 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll 155 | True 156 | 157 | 158 | ..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll 159 | True 160 | 161 | 162 | ..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll 163 | True 164 | 165 | 166 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll 167 | True 168 | 169 | 170 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll 171 | True 172 | 173 | 174 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll 175 | True 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | {2CE1F7FD-852F-495F-9F45-49A2BEDF2346} 198 | Roslinq.Core 199 | 200 | 201 | {C0ADB658-FD53-4A04-A378-AD0FB2AA2F89} 202 | RoslinqTestTarget 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 216 | 217 | 218 | 219 | 220 | 221 | 228 | -------------------------------------------------------------------------------- /Roslinq.Tests.Integration/SolutionTest.cs: -------------------------------------------------------------------------------- 1 | namespace Roslinq.Tests.Integration 2 | { 3 | using NUnit.Framework; 4 | 5 | public class SolutionTest 6 | { 7 | [Test] 8 | public void ManySolutionClassesShouldBePresentTest() 9 | { 10 | var codeQuery = new SolutionQuery(@"..\..\..\Roslinq.sln"); 11 | var classes = codeQuery.Classes.Execute(); 12 | Assert.IsNotNull(classes); 13 | Assert.IsTrue(classes.Count > 2); 14 | } 15 | 16 | [Test] 17 | public void ManyProjectSolutionClassesShouldBePresent() 18 | { 19 | var codeQuery = new SolutionQuery(@"..\..\..\Roslinq.sln"); 20 | var classes = codeQuery.Projects.Classes.Execute(); 21 | Assert.IsNotNull(classes); 22 | Assert.IsTrue(classes.Count > 2); 23 | } 24 | 25 | [Test] 26 | public void ClassesFromDirectSolutionAndClassesFromSolutionProjectsShouldMatch() 27 | { 28 | var solutionQuery1 = new SolutionQuery(@"..\..\..\Roslinq.sln"); 29 | var projectsClasses = solutionQuery1.Projects.Classes.Execute(); 30 | 31 | var solutionQuery2 = new SolutionQuery(@"..\..\..\Roslinq.sln"); 32 | var solutionClasses = solutionQuery2.Classes.Execute(); 33 | 34 | Assert.AreEqual(projectsClasses.Count, solutionClasses.Count); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Roslinq.Tests.Integration/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /Roslinq.Tests.Integration/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Roslinq.Tests/ClassQueryDataTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Roslinq.Tests 8 | { 9 | using Microsoft.CodeAnalysis; 10 | using Microsoft.CodeAnalysis.CSharp; 11 | using Microsoft.CodeAnalysis.CSharp.Syntax; 12 | using NUnit.Framework; 13 | 14 | [TestFixture] 15 | public class ClassQueryDataTests : CompilationTest 16 | { 17 | [Test] 18 | public void InheritsFromTest() 19 | { 20 | string sourceCode = @"class Bar : object {}"; 21 | var semanticModel = CompileAndGetSymanticModel(sourceCode); 22 | var syntaxTree = semanticModel.SyntaxTree; 23 | var barClassSyntax = syntaxTree.GetRoot().DescendantNodes().OfType().ToList()[0]; 24 | var barClassSymbolInfo = semanticModel.GetDeclaredSymbol(barClassSyntax); 25 | var classQuery = new ClassQueryData((INamedTypeSymbol)barClassSymbolInfo); 26 | Assert.True(classQuery.InheritsFrom(typeof(Object))); 27 | } 28 | 29 | [Test] 30 | public void ImplementsInterfaceTest() 31 | { 32 | string sourceCode = @"using System; class Bar : IDisposable { public void Dispose() {} }"; 33 | var semanticModel = CompileAndGetSymanticModel(sourceCode); 34 | var syntaxTree = semanticModel.SyntaxTree; 35 | var barClassSyntax = syntaxTree.GetRoot().DescendantNodes().OfType().ToList()[0]; 36 | var barClassSymbolInfo = semanticModel.GetDeclaredSymbol(barClassSyntax); 37 | var classQuery = new ClassQueryData((INamedTypeSymbol)barClassSymbolInfo); 38 | Assert.True(classQuery.ImplementsInterface(typeof(IDisposable))); 39 | } 40 | 41 | [Test] 42 | public void HasAttributeAppliedTest() 43 | { 44 | string sourceCode = @"using System; [Serializable] class Bar { }"; 45 | var semanticModel = CompileAndGetSymanticModel(sourceCode); 46 | var syntaxTree = semanticModel.SyntaxTree; 47 | var barClassSyntax = syntaxTree.GetRoot().DescendantNodes().OfType().ToList()[0]; 48 | var barClassSymbolInfo = semanticModel.GetDeclaredSymbol(barClassSyntax); 49 | var classQueryData = new ClassQueryData(barClassSymbolInfo); 50 | Assert.IsTrue(classQueryData.HasAttributeApplied(typeof(SerializableAttribute))); 51 | } 52 | 53 | [Test] 54 | public void HasModifier() 55 | { 56 | string sourceCode = @"using System; class Bar { private sealed class Foo { } } "; 57 | var semanticModel = CompileAndGetSymanticModel(sourceCode); 58 | var syntaxTree = semanticModel.SyntaxTree; 59 | var fooClassSyntax = syntaxTree.GetRoot().DescendantNodes().OfType().ToList()[1]; 60 | var fooClassSymbol = semanticModel.GetDeclaredSymbol(fooClassSyntax); 61 | var classQueryData = new ClassQueryData(fooClassSymbol); 62 | Assert.IsTrue(classQueryData.HasModifier(ClassModifier.Private)); 63 | Assert.IsFalse(classQueryData.HasModifier(ClassModifier.Protected)); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Roslinq.Tests/CompilationTest.cs: -------------------------------------------------------------------------------- 1 | namespace Roslinq.Tests 2 | { 3 | using System.Linq; 4 | using Microsoft.CodeAnalysis; 5 | using Microsoft.CodeAnalysis.CSharp; 6 | using NUnit.Framework; 7 | 8 | public class CompilationTest 9 | { 10 | protected SemanticModel CompileAndGetSymanticModel(string sourceCode) 11 | { 12 | var mscorlibAssembly = typeof(object).Assembly; 13 | var mscorlib = MetadataReference.CreateFromFile(mscorlibAssembly.Location); 14 | var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary); 15 | var syntaxTree = CSharpSyntaxTree.ParseText(sourceCode); 16 | var compilation = CSharpCompilation.Create("TestAsm", new[] { syntaxTree }, new[] { mscorlib }, compilationOptions); 17 | var diagnostics = compilation.GetDeclarationDiagnostics().ToList(); 18 | if (diagnostics.Any()) 19 | { 20 | Assert.Fail("compilation error: " + diagnostics[0].GetMessage()); 21 | } 22 | 23 | var semanticModel = compilation.GetSemanticModel(syntaxTree, false); 24 | return semanticModel; 25 | } 26 | 27 | } 28 | } -------------------------------------------------------------------------------- /Roslinq.Tests/InheritanceTests.cs: -------------------------------------------------------------------------------- 1 | namespace Roslinq.Tests 2 | { 3 | using System; 4 | using NUnit.Framework; 5 | 6 | [TestFixture] 7 | public class InheritanceTests 8 | { 9 | [Test] 10 | public void DirectInheritanceTest() 11 | { 12 | Assert.IsTrue(InheritanceHelper.InheritsFrom(typeof(ArgumentException), typeof(SystemException))); 13 | } 14 | 15 | [Test] 16 | public void IndirectInheritanceTest() 17 | { 18 | Assert.IsTrue(InheritanceHelper.InheritsFrom(typeof(ArgumentException), typeof(object))); 19 | } 20 | 21 | [Test] 22 | public void ObjectInheritanceTest() 23 | { 24 | Assert.IsFalse(InheritanceHelper.InheritsFrom(typeof(object), typeof(object))); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Roslinq.Tests/MethodQueryDataTests.cs: -------------------------------------------------------------------------------- 1 | namespace Roslinq.Tests 2 | { 3 | using System; 4 | using System.Collections.Immutable; 5 | using System.Linq; 6 | using Microsoft.CodeAnalysis; 7 | using Microsoft.CodeAnalysis.CSharp; 8 | using Microsoft.CodeAnalysis.CSharp.Syntax; 9 | using NUnit.Framework; 10 | 11 | [TestFixture] 12 | public class MethodQueryDataTests : CompilationTest 13 | { 14 | [Test] 15 | public void MethodExecuteTest() 16 | { 17 | string sourceCode = @"class Bar { public void Foo() {} }"; 18 | var semanticModel = CompileAndGetSymanticModel(sourceCode); 19 | var syntaxTree = semanticModel.SyntaxTree; 20 | var fooMethodSyntax = syntaxTree.GetRoot().DescendantNodes().OfType().ToList()[0]; 21 | var fooMethodSymbol = semanticModel.GetDeclaredSymbol(fooMethodSyntax); 22 | var methodSymbolInfo = new MethodQueryData(fooMethodSymbol); 23 | Assert.AreEqual("Foo", methodSymbolInfo.MethodName); 24 | } 25 | 26 | [Test] 27 | public void MethodReturningTypeTest() 28 | { 29 | string sourceCode = @"class Bar { public int Foo() { return 0; } }"; 30 | 31 | var semanticModel = CompileAndGetSymanticModel(sourceCode); 32 | var syntaxTree = semanticModel.SyntaxTree; 33 | var fooMethodSyntax = syntaxTree.GetRoot().DescendantNodes().OfType().ToList()[0]; 34 | var fooMethodSymbol = semanticModel.GetDeclaredSymbol(fooMethodSyntax); 35 | var methodSymbolInfo = new MethodQueryData(fooMethodSymbol); 36 | Assert.True(methodSymbolInfo.ReturnsType(typeof(int))); 37 | } 38 | 39 | [Test] 40 | public void MethodReturningVoidTest() 41 | { 42 | string sourceCode = @"class Bar { public void Foo() { } }"; 43 | var semanticModel = CompileAndGetSymanticModel(sourceCode); 44 | var syntaxTree = semanticModel.SyntaxTree; 45 | var fooMethodSyntax = syntaxTree.GetRoot().DescendantNodes().OfType().ToList()[0]; 46 | var fooMethodSymbol = semanticModel.GetDeclaredSymbol(fooMethodSyntax); 47 | var methodSymbolInfo = new MethodQueryData(fooMethodSymbol); 48 | Assert.True(methodSymbolInfo.ReturnsType(typeof(void))); 49 | } 50 | 51 | [Test] 52 | public void HasAttributeAppliedTest() 53 | { 54 | string sourceCode = @"using System; class Bar { [Obsolete] public void Foo() { } }"; 55 | var semanticModel = CompileAndGetSymanticModel(sourceCode); 56 | var syntaxTree = semanticModel.SyntaxTree; 57 | var fooMethodSyntax = syntaxTree.GetRoot().DescendantNodes().OfType().ToList()[0]; 58 | var fooMethodSymbol = semanticModel.GetDeclaredSymbol(fooMethodSyntax); 59 | var methodSymbolInfo = new MethodQueryData(fooMethodSymbol); 60 | Assert.True(methodSymbolInfo.HasAttributeApplied(typeof(ObsoleteAttribute))); 61 | } 62 | 63 | [Test] 64 | public void HasParameterTypeTest() 65 | { 66 | string sourceCode = @"using System; class Bar { public int Foo(int a) { return a+1; } }"; 67 | var semanticModel = CompileAndGetSymanticModel(sourceCode); 68 | var syntaxTree = semanticModel.SyntaxTree; 69 | var fooMethodSyntax = syntaxTree.GetRoot().DescendantNodes().OfType().ToList()[0]; 70 | var fooMethodSymbol = semanticModel.GetDeclaredSymbol(fooMethodSyntax); 71 | var methodSymbolInfo = new MethodQueryData(fooMethodSymbol); 72 | Assert.True(methodSymbolInfo.HasParameterType(typeof(int))); 73 | Assert.False(methodSymbolInfo.HasParameterType(typeof(string))); 74 | } 75 | 76 | [Test] 77 | public void HasParameterTypeParamsTest() 78 | { 79 | string sourceCode = @"using System; class Bar { public int Foo(params int[] a) { return 0; } }"; 80 | var semanticModel = CompileAndGetSymanticModel(sourceCode); 81 | var syntaxTree = semanticModel.SyntaxTree; 82 | var fooMethodSyntax = syntaxTree.GetRoot().DescendantNodes().OfType().ToList()[0]; 83 | var fooMethodSymbol = semanticModel.GetDeclaredSymbol(fooMethodSyntax); 84 | var methodSymbolInfo = new MethodQueryData(fooMethodSymbol); 85 | Assert.True(methodSymbolInfo.HasParameterType(typeof(int))); 86 | Assert.False(methodSymbolInfo.HasParameterType(typeof(string))); 87 | } 88 | 89 | [Test] 90 | public void HasModifierTest() 91 | { 92 | string sourceCode = @"using System; class Bar { public virtual int Foo(params int[] a) { return 0; } }"; 93 | var semanticModel = CompileAndGetSymanticModel(sourceCode); 94 | var syntaxTree = semanticModel.SyntaxTree; 95 | var fooMethodSyntax = syntaxTree.GetRoot().DescendantNodes().OfType().ToList()[0]; 96 | var fooMethodSymbol = semanticModel.GetDeclaredSymbol(fooMethodSyntax); 97 | var methodSymbolInfo = new MethodQueryData(fooMethodSymbol); 98 | Assert.IsTrue(methodSymbolInfo.HasModifier(MethodModifier.Virtual)); 99 | Assert.IsFalse(methodSymbolInfo.HasModifier(MethodModifier.Protected)); 100 | } 101 | } 102 | } -------------------------------------------------------------------------------- /Roslinq.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Roslinq.Tests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Roslinq.Tests")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("66f4e61f-6616-414a-a57f-39858b00e23c")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Roslinq.Tests/Roslinq.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {66F4E61F-6616-414A-A57F-39858B00E23C} 8 | Library 9 | Properties 10 | Roslinq.Tests 11 | Roslinq.Tests 12 | v4.7.2 13 | 512 14 | 15 | 16 | 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | ..\packages\Humanizer.Core.2.8.26\lib\netstandard2.0\Humanizer.dll 38 | 39 | 40 | ..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll 41 | 42 | 43 | ..\packages\Microsoft.Build.Framework.16.8.0\lib\net472\Microsoft.Build.Framework.dll 44 | 45 | 46 | ..\packages\Microsoft.Build.Tasks.Core.16.8.0\lib\net472\Microsoft.Build.Tasks.Core.dll 47 | 48 | 49 | ..\packages\Microsoft.Build.Utilities.Core.16.8.0\lib\net472\Microsoft.Build.Utilities.Core.dll 50 | 51 | 52 | ..\packages\Microsoft.CodeAnalysis.Common.3.8.0\lib\netstandard2.0\Microsoft.CodeAnalysis.dll 53 | 54 | 55 | ..\packages\Microsoft.CodeAnalysis.CSharp.3.8.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll 56 | 57 | 58 | ..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.3.8.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Workspaces.dll 59 | 60 | 61 | ..\packages\Microsoft.CodeAnalysis.VisualBasic.3.8.0\lib\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.dll 62 | 63 | 64 | ..\packages\Microsoft.CodeAnalysis.VisualBasic.Workspaces.3.8.0\lib\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll 65 | 66 | 67 | ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.3.8.0\lib\netstandard2.0\Microsoft.CodeAnalysis.Workspaces.dll 68 | 69 | 70 | ..\packages\Microsoft.VisualStudio.Setup.Configuration.Interop.1.16.30\lib\net35\Microsoft.VisualStudio.Setup.Configuration.Interop.dll 71 | True 72 | 73 | 74 | ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.dll 75 | True 76 | 77 | 78 | ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.interfaces.dll 79 | True 80 | 81 | 82 | ..\packages\NUnit.2.6.4\lib\nunit.framework.dll 83 | True 84 | 85 | 86 | ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.util.dll 87 | True 88 | 89 | 90 | ..\packages\NUnitTestAdapter.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll 91 | True 92 | 93 | 94 | 95 | ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll 96 | 97 | 98 | ..\packages\System.Collections.Immutable.5.0.0\lib\net461\System.Collections.Immutable.dll 99 | 100 | 101 | 102 | ..\packages\System.Composition.AttributedModel.5.0.1\lib\net461\System.Composition.AttributedModel.dll 103 | 104 | 105 | ..\packages\System.Composition.Convention.5.0.1\lib\net461\System.Composition.Convention.dll 106 | 107 | 108 | ..\packages\System.Composition.Hosting.5.0.1\lib\net461\System.Composition.Hosting.dll 109 | 110 | 111 | ..\packages\System.Composition.Runtime.5.0.1\lib\net461\System.Composition.Runtime.dll 112 | 113 | 114 | ..\packages\System.Composition.TypedParts.5.0.1\lib\net461\System.Composition.TypedParts.dll 115 | 116 | 117 | 118 | 119 | 120 | ..\packages\System.Linq.4.3.0\lib\net463\System.Linq.dll 121 | True 122 | True 123 | 124 | 125 | ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll 126 | 127 | 128 | 129 | ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll 130 | 131 | 132 | ..\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll 133 | True 134 | True 135 | 136 | 137 | ..\packages\System.Reflection.Metadata.5.0.0\lib\net461\System.Reflection.Metadata.dll 138 | 139 | 140 | ..\packages\System.Resources.Extensions.4.6.0\lib\netstandard2.0\System.Resources.Extensions.dll 141 | 142 | 143 | ..\packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll 144 | True 145 | True 146 | 147 | 148 | ..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll 149 | 150 | 151 | ..\packages\System.Runtime.Extensions.4.3.1\lib\net462\System.Runtime.Extensions.dll 152 | True 153 | True 154 | 155 | 156 | ..\packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll 157 | True 158 | True 159 | 160 | 161 | 162 | 163 | ..\packages\System.Text.Encoding.CodePages.5.0.0\lib\net461\System.Text.Encoding.CodePages.dll 164 | 165 | 166 | ..\packages\System.Threading.Tasks.Dataflow.5.0.0\lib\net461\System.Threading.Tasks.Dataflow.dll 167 | 168 | 169 | ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | {2CE1F7FD-852F-495F-9F45-49A2BEDF2346} 195 | Roslinq.Core 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 209 | 210 | 211 | 212 | 213 | 214 | 221 | -------------------------------------------------------------------------------- /Roslinq.Tests/TypeComparisonTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Roslinq.Tests 8 | { 9 | using Microsoft.CodeAnalysis; 10 | using Microsoft.CodeAnalysis.CSharp; 11 | using Microsoft.CodeAnalysis.CSharp.Syntax; 12 | using NUnit.Framework; 13 | 14 | [TestFixture] 15 | public class TypeComparisonTests 16 | { 17 | [Test] 18 | public void SameTypesShouldMatch() 19 | { 20 | string sourceCode = @"class Bar : object {}"; 21 | 22 | var mscorlibAssembly = typeof(object).Assembly; 23 | var mscorlib = MetadataReference.CreateFromFile(mscorlibAssembly.Location); 24 | var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary); 25 | var syntaxTree = CSharpSyntaxTree.ParseText(sourceCode); 26 | var compilation = CSharpCompilation.Create("TestAsm", new[] { syntaxTree }, new[] { mscorlib }, compilationOptions); 27 | 28 | var semanticModel = compilation.GetSemanticModel(syntaxTree, false); 29 | var barClassSyntax = syntaxTree.GetRoot().DescendantNodes().OfType().ToList()[0]; 30 | var barClassSymbolInfo = semanticModel.GetDeclaredSymbol(barClassSyntax); 31 | var classBarBaseTypeSymbolInfo = barClassSymbolInfo.BaseType; 32 | 33 | Assert.True(TypeComparer.TypesMatch(classBarBaseTypeSymbolInfo, typeof(object))); 34 | } 35 | 36 | [Test] 37 | public void NonTrivialTypesShouldNotMatch() 38 | { 39 | string sourceCode = @"using System; public class MyException : Exception { }"; 40 | 41 | var mscorlibAssembly = typeof(object).Assembly; 42 | var mscorlib = MetadataReference.CreateFromFile(mscorlibAssembly.Location); 43 | var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary); 44 | var syntaxTree = CSharpSyntaxTree.ParseText(sourceCode); 45 | var compilation = CSharpCompilation.Create("TestAsm", new[] { syntaxTree }, new[] { mscorlib }, compilationOptions); 46 | 47 | if (compilation.GetDiagnostics().Any()) 48 | { 49 | Assert.Fail("compilation failed"); 50 | } 51 | 52 | var semanticModel = compilation.GetSemanticModel(syntaxTree, false); 53 | var interfaceDeclarationSyntax = syntaxTree.GetRoot().DescendantNodes().OfType().ToList()[0]; 54 | var interfaceSymbol = semanticModel.GetDeclaredSymbol(interfaceDeclarationSyntax); 55 | 56 | Assert.False(TypeComparer.TypesMatch(interfaceSymbol, typeof(Exception))); 57 | } 58 | 59 | [Test] 60 | public void TypesWithSameNameOnlyShouldNotMatch() 61 | { 62 | string sourceCode = @"public interface ICloneable { }"; 63 | 64 | var mscorlibAssembly = typeof(object).Assembly; 65 | var mscorlib = MetadataReference.CreateFromFile(mscorlibAssembly.Location); 66 | var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary); 67 | var syntaxTree = CSharpSyntaxTree.ParseText(sourceCode); 68 | var compilation = CSharpCompilation.Create("TestAsm", new[] { syntaxTree }, new[] { mscorlib }, compilationOptions); 69 | 70 | if (compilation.GetDiagnostics().Any()) 71 | { 72 | Assert.Fail("compilation failed"); 73 | } 74 | 75 | var semanticModel = compilation.GetSemanticModel(syntaxTree, false); 76 | var interfaceDeclarationSyntax = syntaxTree.GetRoot().DescendantNodes().OfType().ToList()[0]; 77 | var interfaceSymbol = semanticModel.GetDeclaredSymbol(interfaceDeclarationSyntax); 78 | 79 | Assert.False(TypeComparer.TypesMatch(interfaceSymbol, typeof(ICloneable))); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Roslinq.Tests/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Roslinq.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Roslinq.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31005.135 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Roslinq.Core", "Roslinq.Core\Roslinq.Core.csproj", "{2CE1F7FD-852F-495F-9F45-49A2BEDF2346}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Roslinq.Tests", "Roslinq.Tests\Roslinq.Tests.csproj", "{66F4E61F-6616-414A-A57F-39858B00E23C}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RoslinqTestTarget", "RoslinqTestTarget\RoslinqTestTarget.csproj", "{C0ADB658-FD53-4A04-A378-AD0FB2AA2F89}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Roslinq.Tests.Integration", "Roslinq.Tests.Integration\Roslinq.Tests.Integration.csproj", "{1CB097A6-7425-40C8-A13D-8346ED1291EB}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {2CE1F7FD-852F-495F-9F45-49A2BEDF2346}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {2CE1F7FD-852F-495F-9F45-49A2BEDF2346}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {2CE1F7FD-852F-495F-9F45-49A2BEDF2346}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {2CE1F7FD-852F-495F-9F45-49A2BEDF2346}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {66F4E61F-6616-414A-A57F-39858B00E23C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {66F4E61F-6616-414A-A57F-39858B00E23C}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {66F4E61F-6616-414A-A57F-39858B00E23C}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {66F4E61F-6616-414A-A57F-39858B00E23C}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {C0ADB658-FD53-4A04-A378-AD0FB2AA2F89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {C0ADB658-FD53-4A04-A378-AD0FB2AA2F89}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {C0ADB658-FD53-4A04-A378-AD0FB2AA2F89}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {C0ADB658-FD53-4A04-A378-AD0FB2AA2F89}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {1CB097A6-7425-40C8-A13D-8346ED1291EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {1CB097A6-7425-40C8-A13D-8346ED1291EB}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {1CB097A6-7425-40C8-A13D-8346ED1291EB}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {1CB097A6-7425-40C8-A13D-8346ED1291EB}.Release|Any CPU.Build.0 = Release|Any CPU 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | GlobalSection(ExtensibilityGlobals) = postSolution 41 | SolutionGuid = {4BF32C3E-3411-4E94-BC3D-29159AEC3779} 42 | EndGlobalSection 43 | EndGlobal 44 | -------------------------------------------------------------------------------- /RoslinqTestTarget/AppCode/InternalLogic.cs: -------------------------------------------------------------------------------- 1 | namespace RoslinqTestTarget.AppCode 2 | { 3 | internal class InternalLogic 4 | { 5 | internal static void MethodA() 6 | { 7 | 8 | } 9 | 10 | private static void MethodB() 11 | { 12 | 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /RoslinqTestTarget/App_Start/BundleConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Optimization; 3 | 4 | namespace RoslinqTestTarget 5 | { 6 | public class BundleConfig 7 | { 8 | // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862 9 | public static void RegisterBundles(BundleCollection bundles) 10 | { 11 | bundles.Add(new ScriptBundle("~/bundles/jquery").Include( 12 | "~/Scripts/jquery-{version}.js")); 13 | 14 | bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( 15 | "~/Scripts/jquery.validate*")); 16 | 17 | // Use the development version of Modernizr to develop with and learn from. Then, when you're 18 | // ready for production, use the build tool at http://modernizr.com to pick only the tests you need. 19 | bundles.Add(new ScriptBundle("~/bundles/modernizr").Include( 20 | "~/Scripts/modernizr-*")); 21 | 22 | bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include( 23 | "~/Scripts/bootstrap.js", 24 | "~/Scripts/respond.js")); 25 | 26 | bundles.Add(new StyleBundle("~/Content/css").Include( 27 | "~/Content/bootstrap.css", 28 | "~/Content/site.css")); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /RoslinqTestTarget/App_Start/FilterConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Mvc; 3 | 4 | namespace RoslinqTestTarget 5 | { 6 | public class FilterConfig 7 | { 8 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 9 | { 10 | filters.Add(new HandleErrorAttribute()); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /RoslinqTestTarget/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | 8 | namespace RoslinqTestTarget 9 | { 10 | public class RouteConfig 11 | { 12 | public static void RegisterRoutes(RouteCollection routes) 13 | { 14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 15 | 16 | routes.MapRoute( 17 | name: "Default", 18 | url: "{controller}/{action}/{id}", 19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 20 | ); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /RoslinqTestTarget/Content/Site.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 50px; 3 | padding-bottom: 20px; 4 | } 5 | 6 | /* Set padding to keep content from hitting the edges */ 7 | .body-content { 8 | padding-left: 15px; 9 | padding-right: 15px; 10 | } 11 | 12 | /* Override the default bootstrap behavior where horizontal description lists 13 | will truncate terms that are too long to fit in the left column 14 | */ 15 | .dl-horizontal dt { 16 | white-space: normal; 17 | } 18 | 19 | /* Set width on the form input elements since they're 100% wide by default */ 20 | input, 21 | select, 22 | textarea { 23 | max-width: 280px; 24 | } 25 | -------------------------------------------------------------------------------- /RoslinqTestTarget/Controllers/AdminController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | 6 | namespace RoslinqTestTarget.Controllers 7 | { 8 | using System.Web.Mvc; 9 | 10 | public class AdminController : Controller, IController 11 | { 12 | } 13 | } -------------------------------------------------------------------------------- /RoslinqTestTarget/Controllers/AdminReportingController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | 6 | namespace RoslinqTestTarget.Controllers 7 | { 8 | using System.Web.Mvc; 9 | using Models; 10 | 11 | public class AdminReportingController : AdminController 12 | { 13 | public ActionResult Baz(SerializableModel model) 14 | { 15 | return View(); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /RoslinqTestTarget/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | 7 | namespace RoslinqTestTarget.Controllers 8 | { 9 | public class HomeController : Controller 10 | { 11 | public ActionResult Index() 12 | { 13 | return View(); 14 | } 15 | 16 | public ActionResult About() 17 | { 18 | ViewBag.Message = "Your application description page."; 19 | 20 | return View(); 21 | } 22 | 23 | public ActionResult Contact() 24 | { 25 | ViewBag.Message = "Your contact page."; 26 | 27 | return View(); 28 | } 29 | 30 | public PartialViewResult Partial() 31 | { 32 | return Partial(); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /RoslinqTestTarget/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="RoslinqTestTarget.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /RoslinqTestTarget/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Optimization; 7 | using System.Web.Routing; 8 | 9 | namespace RoslinqTestTarget 10 | { 11 | public class MvcApplication : System.Web.HttpApplication 12 | { 13 | protected void Application_Start() 14 | { 15 | AreaRegistration.RegisterAllAreas(); 16 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 17 | RouteConfig.RegisterRoutes(RouteTable.Routes); 18 | BundleConfig.RegisterBundles(BundleTable.Bundles); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /RoslinqTestTarget/Models/SerializableModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | 6 | namespace RoslinqTestTarget.Models 7 | { 8 | [Serializable] 9 | public class SerializableModel 10 | { 11 | public string Foo { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /RoslinqTestTarget/Project_Readme.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Your ASP.NET application 6 | 95 | 96 | 97 | 98 | 102 | 103 |
104 |
105 |

This application consists of:

106 |
    107 |
  • Sample pages showing basic nav between Home, About, and Contact
  • 108 |
  • Theming using Bootstrap
  • 109 |
  • Authentication, if selected, shows how to register and sign in
  • 110 |
  • ASP.NET features managed using NuGet
  • 111 |
112 |
113 | 114 | 131 | 132 |
133 |

Deploy

134 | 139 |
140 | 141 |
142 |

Get help

143 | 147 |
148 |
149 | 150 | 151 | -------------------------------------------------------------------------------- /RoslinqTestTarget/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RoslinqTestTarget")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("RoslinqTestTarget")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("3fdb4eed-f737-4c9b-aa6a-3105bef83e79")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /RoslinqTestTarget/RoslinqTestTarget.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 8 | 9 | 2.0 10 | {C0ADB658-FD53-4A04-A378-AD0FB2AA2F89} 11 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 12 | Library 13 | Properties 14 | RoslinqTestTarget 15 | RoslinqTestTarget 16 | v4.7.2 17 | false 18 | true 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | true 29 | full 30 | false 31 | bin\ 32 | DEBUG;TRACE 33 | prompt 34 | 4 35 | 36 | 37 | pdbonly 38 | true 39 | bin\ 40 | TRACE 41 | prompt 42 | 4 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | True 64 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 65 | 66 | 67 | 68 | 69 | 70 | 71 | True 72 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll 73 | 74 | 75 | True 76 | ..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll 77 | 78 | 79 | ..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll 80 | 81 | 82 | True 83 | ..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll 84 | 85 | 86 | True 87 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll 88 | 89 | 90 | True 91 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll 92 | 93 | 94 | True 95 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll 96 | 97 | 98 | 99 | True 100 | ..\packages\WebGrease.1.5.2\lib\WebGrease.dll 101 | 102 | 103 | True 104 | ..\packages\Antlr.3.4.1.9004\lib\Antlr3.Runtime.dll 105 | 106 | 107 | 108 | 109 | ..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | Global.asax 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | Web.config 147 | 148 | 149 | Web.config 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 10.0 169 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | True 182 | True 183 | 7602 184 | / 185 | http://localhost:7602/ 186 | False 187 | False 188 | 189 | 190 | False 191 | 192 | 193 | 194 | 195 | 201 | -------------------------------------------------------------------------------- /RoslinqTestTarget/Scripts/_references.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benetkiewicz/Roslinq/41e1159860632055e0b5891bc5921a1b8e49007a/RoslinqTestTarget/Scripts/_references.js -------------------------------------------------------------------------------- /RoslinqTestTarget/Scripts/jquery.validate.min.js: -------------------------------------------------------------------------------- 1 | /* NUGET: BEGIN LICENSE TEXT 2 | * 3 | * Microsoft grants you the right to use these script files for the sole 4 | * purpose of either: (i) interacting through your browser with the Microsoft 5 | * website or online service, subject to the applicable licensing or use 6 | * terms; or (ii) using the files as included with a Microsoft product subject 7 | * to that product's license terms. Microsoft reserves all other rights to the 8 | * files not expressly granted by Microsoft, whether by implication, estoppel 9 | * or otherwise. Insofar as a script file is dual licensed under GPL, 10 | * Microsoft neither took the code under GPL nor distributes it thereunder but 11 | * under the terms set out in this paragraph. All notices and licenses 12 | * below are for informational purposes only. 13 | * 14 | * NUGET: END LICENSE TEXT */ 15 | /*! jQuery Validation Plugin - v1.11.1 - 3/22/2013\n* https://github.com/jzaefferer/jquery-validation 16 | * Copyright (c) 2013 Jörn Zaefferer; Licensed MIT */(function(t){t.extend(t.fn,{validate:function(e){if(!this.length)return e&&e.debug&&window.console&&console.warn("Nothing selected, can't validate, returning nothing."),void 0;var i=t.data(this[0],"validator");return i?i:(this.attr("novalidate","novalidate"),i=new t.validator(e,this[0]),t.data(this[0],"validator",i),i.settings.onsubmit&&(this.validateDelegate(":submit","click",function(e){i.settings.submitHandler&&(i.submitButton=e.target),t(e.target).hasClass("cancel")&&(i.cancelSubmit=!0),void 0!==t(e.target).attr("formnovalidate")&&(i.cancelSubmit=!0)}),this.submit(function(e){function s(){var s;return i.settings.submitHandler?(i.submitButton&&(s=t("").attr("name",i.submitButton.name).val(t(i.submitButton).val()).appendTo(i.currentForm)),i.settings.submitHandler.call(i,i.currentForm,e),i.submitButton&&s.remove(),!1):!0}return i.settings.debug&&e.preventDefault(),i.cancelSubmit?(i.cancelSubmit=!1,s()):i.form()?i.pendingRequest?(i.formSubmitted=!0,!1):s():(i.focusInvalid(),!1)})),i)},valid:function(){if(t(this[0]).is("form"))return this.validate().form();var e=!0,i=t(this[0].form).validate();return this.each(function(){e=e&&i.element(this)}),e},removeAttrs:function(e){var i={},s=this;return t.each(e.split(/\s/),function(t,e){i[e]=s.attr(e),s.removeAttr(e)}),i},rules:function(e,i){var s=this[0];if(e){var r=t.data(s.form,"validator").settings,n=r.rules,a=t.validator.staticRules(s);switch(e){case"add":t.extend(a,t.validator.normalizeRule(i)),delete a.messages,n[s.name]=a,i.messages&&(r.messages[s.name]=t.extend(r.messages[s.name],i.messages));break;case"remove":if(!i)return delete n[s.name],a;var u={};return t.each(i.split(/\s/),function(t,e){u[e]=a[e],delete a[e]}),u}}var o=t.validator.normalizeRules(t.extend({},t.validator.classRules(s),t.validator.attributeRules(s),t.validator.dataRules(s),t.validator.staticRules(s)),s);if(o.required){var l=o.required;delete o.required,o=t.extend({required:l},o)}return o}}),t.extend(t.expr[":"],{blank:function(e){return!t.trim(""+t(e).val())},filled:function(e){return!!t.trim(""+t(e).val())},unchecked:function(e){return!t(e).prop("checked")}}),t.validator=function(e,i){this.settings=t.extend(!0,{},t.validator.defaults,e),this.currentForm=i,this.init()},t.validator.format=function(e,i){return 1===arguments.length?function(){var i=t.makeArray(arguments);return i.unshift(e),t.validator.format.apply(this,i)}:(arguments.length>2&&i.constructor!==Array&&(i=t.makeArray(arguments).slice(1)),i.constructor!==Array&&(i=[i]),t.each(i,function(t,i){e=e.replace(RegExp("\\{"+t+"\\}","g"),function(){return i})}),e)},t.extend(t.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",validClass:"valid",errorElement:"label",focusInvalid:!0,errorContainer:t([]),errorLabelContainer:t([]),onsubmit:!0,ignore:":hidden",ignoreTitle:!1,onfocusin:function(t){this.lastActive=t,this.settings.focusCleanup&&!this.blockFocusCleanup&&(this.settings.unhighlight&&this.settings.unhighlight.call(this,t,this.settings.errorClass,this.settings.validClass),this.addWrapper(this.errorsFor(t)).hide())},onfocusout:function(t){this.checkable(t)||!(t.name in this.submitted)&&this.optional(t)||this.element(t)},onkeyup:function(t,e){(9!==e.which||""!==this.elementValue(t))&&(t.name in this.submitted||t===this.lastElement)&&this.element(t)},onclick:function(t){t.name in this.submitted?this.element(t):t.parentNode.name in this.submitted&&this.element(t.parentNode)},highlight:function(e,i,s){"radio"===e.type?this.findByName(e.name).addClass(i).removeClass(s):t(e).addClass(i).removeClass(s)},unhighlight:function(e,i,s){"radio"===e.type?this.findByName(e.name).removeClass(i).addClass(s):t(e).removeClass(i).addClass(s)}},setDefaults:function(e){t.extend(t.validator.defaults,e)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",maxlength:t.validator.format("Please enter no more than {0} characters."),minlength:t.validator.format("Please enter at least {0} characters."),rangelength:t.validator.format("Please enter a value between {0} and {1} characters long."),range:t.validator.format("Please enter a value between {0} and {1}."),max:t.validator.format("Please enter a value less than or equal to {0}."),min:t.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:!1,prototype:{init:function(){function e(e){var i=t.data(this[0].form,"validator"),s="on"+e.type.replace(/^validate/,"");i.settings[s]&&i.settings[s].call(i,this[0],e)}this.labelContainer=t(this.settings.errorLabelContainer),this.errorContext=this.labelContainer.length&&this.labelContainer||t(this.currentForm),this.containers=t(this.settings.errorContainer).add(this.settings.errorLabelContainer),this.submitted={},this.valueCache={},this.pendingRequest=0,this.pending={},this.invalid={},this.reset();var i=this.groups={};t.each(this.settings.groups,function(e,s){"string"==typeof s&&(s=s.split(/\s/)),t.each(s,function(t,s){i[s]=e})});var s=this.settings.rules;t.each(s,function(e,i){s[e]=t.validator.normalizeRule(i)}),t(this.currentForm).validateDelegate(":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'] ,[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'] ","focusin focusout keyup",e).validateDelegate("[type='radio'], [type='checkbox'], select, option","click",e),this.settings.invalidHandler&&t(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler)},form:function(){return this.checkForm(),t.extend(this.submitted,this.errorMap),this.invalid=t.extend({},this.errorMap),this.valid()||t(this.currentForm).triggerHandler("invalid-form",[this]),this.showErrors(),this.valid()},checkForm:function(){this.prepareForm();for(var t=0,e=this.currentElements=this.elements();e[t];t++)this.check(e[t]);return this.valid()},element:function(e){e=this.validationTargetFor(this.clean(e)),this.lastElement=e,this.prepareElement(e),this.currentElements=t(e);var i=this.check(e)!==!1;return i?delete this.invalid[e.name]:this.invalid[e.name]=!0,this.numberOfInvalids()||(this.toHide=this.toHide.add(this.containers)),this.showErrors(),i},showErrors:function(e){if(e){t.extend(this.errorMap,e),this.errorList=[];for(var i in e)this.errorList.push({message:e[i],element:this.findByName(i)[0]});this.successList=t.grep(this.successList,function(t){return!(t.name in e)})}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){t.fn.resetForm&&t(this.currentForm).resetForm(),this.submitted={},this.lastElement=null,this.prepareForm(),this.hideErrors(),this.elements().removeClass(this.settings.errorClass).removeData("previousValue")},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(t){var e=0;for(var i in t)e++;return e},hideErrors:function(){this.addWrapper(this.toHide).hide()},valid:function(){return 0===this.size()},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{t(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(e){}},findLastActive:function(){var e=this.lastActive;return e&&1===t.grep(this.errorList,function(t){return t.element.name===e.name}).length&&e},elements:function(){var e=this,i={};return t(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){return!this.name&&e.settings.debug&&window.console&&console.error("%o has no name assigned",this),this.name in i||!e.objectLength(t(this).rules())?!1:(i[this.name]=!0,!0)})},clean:function(e){return t(e)[0]},errors:function(){var e=this.settings.errorClass.replace(" ",".");return t(this.settings.errorElement+"."+e,this.errorContext)},reset:function(){this.successList=[],this.errorList=[],this.errorMap={},this.toShow=t([]),this.toHide=t([]),this.currentElements=t([])},prepareForm:function(){this.reset(),this.toHide=this.errors().add(this.containers)},prepareElement:function(t){this.reset(),this.toHide=this.errorsFor(t)},elementValue:function(e){var i=t(e).attr("type"),s=t(e).val();return"radio"===i||"checkbox"===i?t("input[name='"+t(e).attr("name")+"']:checked").val():"string"==typeof s?s.replace(/\r/g,""):s},check:function(e){e=this.validationTargetFor(this.clean(e));var i,s=t(e).rules(),r=!1,n=this.elementValue(e);for(var a in s){var u={method:a,parameters:s[a]};try{if(i=t.validator.methods[a].call(this,n,e,u.parameters),"dependency-mismatch"===i){r=!0;continue}if(r=!1,"pending"===i)return this.toHide=this.toHide.not(this.errorsFor(e)),void 0;if(!i)return this.formatAndAdd(e,u),!1}catch(o){throw this.settings.debug&&window.console&&console.log("Exception occurred when checking element "+e.id+", check the '"+u.method+"' method.",o),o}}return r?void 0:(this.objectLength(s)&&this.successList.push(e),!0)},customDataMessage:function(e,i){return t(e).data("msg-"+i.toLowerCase())||e.attributes&&t(e).attr("data-msg-"+i.toLowerCase())},customMessage:function(t,e){var i=this.settings.messages[t];return i&&(i.constructor===String?i:i[e])},findDefined:function(){for(var t=0;arguments.length>t;t++)if(void 0!==arguments[t])return arguments[t];return void 0},defaultMessage:function(e,i){return this.findDefined(this.customMessage(e.name,i),this.customDataMessage(e,i),!this.settings.ignoreTitle&&e.title||void 0,t.validator.messages[i],"Warning: No message defined for "+e.name+"")},formatAndAdd:function(e,i){var s=this.defaultMessage(e,i.method),r=/\$?\{(\d+)\}/g;"function"==typeof s?s=s.call(this,i.parameters,e):r.test(s)&&(s=t.validator.format(s.replace(r,"{$1}"),i.parameters)),this.errorList.push({message:s,element:e}),this.errorMap[e.name]=s,this.submitted[e.name]=s},addWrapper:function(t){return this.settings.wrapper&&(t=t.add(t.parent(this.settings.wrapper))),t},defaultShowErrors:function(){var t,e;for(t=0;this.errorList[t];t++){var i=this.errorList[t];this.settings.highlight&&this.settings.highlight.call(this,i.element,this.settings.errorClass,this.settings.validClass),this.showLabel(i.element,i.message)}if(this.errorList.length&&(this.toShow=this.toShow.add(this.containers)),this.settings.success)for(t=0;this.successList[t];t++)this.showLabel(this.successList[t]);if(this.settings.unhighlight)for(t=0,e=this.validElements();e[t];t++)this.settings.unhighlight.call(this,e[t],this.settings.errorClass,this.settings.validClass);this.toHide=this.toHide.not(this.toShow),this.hideErrors(),this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return t(this.errorList).map(function(){return this.element})},showLabel:function(e,i){var s=this.errorsFor(e);s.length?(s.removeClass(this.settings.validClass).addClass(this.settings.errorClass),s.html(i)):(s=t("<"+this.settings.errorElement+">").attr("for",this.idOrName(e)).addClass(this.settings.errorClass).html(i||""),this.settings.wrapper&&(s=s.hide().show().wrap("<"+this.settings.wrapper+"/>").parent()),this.labelContainer.append(s).length||(this.settings.errorPlacement?this.settings.errorPlacement(s,t(e)):s.insertAfter(e))),!i&&this.settings.success&&(s.text(""),"string"==typeof this.settings.success?s.addClass(this.settings.success):this.settings.success(s,e)),this.toShow=this.toShow.add(s)},errorsFor:function(e){var i=this.idOrName(e);return this.errors().filter(function(){return t(this).attr("for")===i})},idOrName:function(t){return this.groups[t.name]||(this.checkable(t)?t.name:t.id||t.name)},validationTargetFor:function(t){return this.checkable(t)&&(t=this.findByName(t.name).not(this.settings.ignore)[0]),t},checkable:function(t){return/radio|checkbox/i.test(t.type)},findByName:function(e){return t(this.currentForm).find("[name='"+e+"']")},getLength:function(e,i){switch(i.nodeName.toLowerCase()){case"select":return t("option:selected",i).length;case"input":if(this.checkable(i))return this.findByName(i.name).filter(":checked").length}return e.length},depend:function(t,e){return this.dependTypes[typeof t]?this.dependTypes[typeof t](t,e):!0},dependTypes:{"boolean":function(t){return t},string:function(e,i){return!!t(e,i.form).length},"function":function(t,e){return t(e)}},optional:function(e){var i=this.elementValue(e);return!t.validator.methods.required.call(this,i,e)&&"dependency-mismatch"},startRequest:function(t){this.pending[t.name]||(this.pendingRequest++,this.pending[t.name]=!0)},stopRequest:function(e,i){this.pendingRequest--,0>this.pendingRequest&&(this.pendingRequest=0),delete this.pending[e.name],i&&0===this.pendingRequest&&this.formSubmitted&&this.form()?(t(this.currentForm).submit(),this.formSubmitted=!1):!i&&0===this.pendingRequest&&this.formSubmitted&&(t(this.currentForm).triggerHandler("invalid-form",[this]),this.formSubmitted=!1)},previousValue:function(e){return t.data(e,"previousValue")||t.data(e,"previousValue",{old:null,valid:!0,message:this.defaultMessage(e,"remote")})}},classRuleSettings:{required:{required:!0},email:{email:!0},url:{url:!0},date:{date:!0},dateISO:{dateISO:!0},number:{number:!0},digits:{digits:!0},creditcard:{creditcard:!0}},addClassRules:function(e,i){e.constructor===String?this.classRuleSettings[e]=i:t.extend(this.classRuleSettings,e)},classRules:function(e){var i={},s=t(e).attr("class");return s&&t.each(s.split(" "),function(){this in t.validator.classRuleSettings&&t.extend(i,t.validator.classRuleSettings[this])}),i},attributeRules:function(e){var i={},s=t(e),r=s[0].getAttribute("type");for(var n in t.validator.methods){var a;"required"===n?(a=s.get(0).getAttribute(n),""===a&&(a=!0),a=!!a):a=s.attr(n),/min|max/.test(n)&&(null===r||/number|range|text/.test(r))&&(a=Number(a)),a?i[n]=a:r===n&&"range"!==r&&(i[n]=!0)}return i.maxlength&&/-1|2147483647|524288/.test(i.maxlength)&&delete i.maxlength,i},dataRules:function(e){var i,s,r={},n=t(e);for(i in t.validator.methods)s=n.data("rule-"+i.toLowerCase()),void 0!==s&&(r[i]=s);return r},staticRules:function(e){var i={},s=t.data(e.form,"validator");return s.settings.rules&&(i=t.validator.normalizeRule(s.settings.rules[e.name])||{}),i},normalizeRules:function(e,i){return t.each(e,function(s,r){if(r===!1)return delete e[s],void 0;if(r.param||r.depends){var n=!0;switch(typeof r.depends){case"string":n=!!t(r.depends,i.form).length;break;case"function":n=r.depends.call(i,i)}n?e[s]=void 0!==r.param?r.param:!0:delete e[s]}}),t.each(e,function(s,r){e[s]=t.isFunction(r)?r(i):r}),t.each(["minlength","maxlength"],function(){e[this]&&(e[this]=Number(e[this]))}),t.each(["rangelength","range"],function(){var i;e[this]&&(t.isArray(e[this])?e[this]=[Number(e[this][0]),Number(e[this][1])]:"string"==typeof e[this]&&(i=e[this].split(/[\s,]+/),e[this]=[Number(i[0]),Number(i[1])]))}),t.validator.autoCreateRanges&&(e.min&&e.max&&(e.range=[e.min,e.max],delete e.min,delete e.max),e.minlength&&e.maxlength&&(e.rangelength=[e.minlength,e.maxlength],delete e.minlength,delete e.maxlength)),e},normalizeRule:function(e){if("string"==typeof e){var i={};t.each(e.split(/\s/),function(){i[this]=!0}),e=i}return e},addMethod:function(e,i,s){t.validator.methods[e]=i,t.validator.messages[e]=void 0!==s?s:t.validator.messages[e],3>i.length&&t.validator.addClassRules(e,t.validator.normalizeRule(e))},methods:{required:function(e,i,s){if(!this.depend(s,i))return"dependency-mismatch";if("select"===i.nodeName.toLowerCase()){var r=t(i).val();return r&&r.length>0}return this.checkable(i)?this.getLength(e,i)>0:t.trim(e).length>0},email:function(t,e){return this.optional(e)||/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(t)},url:function(t,e){return this.optional(e)||/^(https?|s?ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(t)},date:function(t,e){return this.optional(e)||!/Invalid|NaN/.test(""+new Date(t))},dateISO:function(t,e){return this.optional(e)||/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/.test(t)},number:function(t,e){return this.optional(e)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(t)},digits:function(t,e){return this.optional(e)||/^\d+$/.test(t)},creditcard:function(t,e){if(this.optional(e))return"dependency-mismatch";if(/[^0-9 \-]+/.test(t))return!1;var i=0,s=0,r=!1;t=t.replace(/\D/g,"");for(var n=t.length-1;n>=0;n--){var a=t.charAt(n);s=parseInt(a,10),r&&(s*=2)>9&&(s-=9),i+=s,r=!r}return 0===i%10},minlength:function(e,i,s){var r=t.isArray(e)?e.length:this.getLength(t.trim(e),i);return this.optional(i)||r>=s},maxlength:function(e,i,s){var r=t.isArray(e)?e.length:this.getLength(t.trim(e),i);return this.optional(i)||s>=r},rangelength:function(e,i,s){var r=t.isArray(e)?e.length:this.getLength(t.trim(e),i);return this.optional(i)||r>=s[0]&&s[1]>=r},min:function(t,e,i){return this.optional(e)||t>=i},max:function(t,e,i){return this.optional(e)||i>=t},range:function(t,e,i){return this.optional(e)||t>=i[0]&&i[1]>=t},equalTo:function(e,i,s){var r=t(s);return this.settings.onfocusout&&r.unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){t(i).valid()}),e===r.val()},remote:function(e,i,s){if(this.optional(i))return"dependency-mismatch";var r=this.previousValue(i);if(this.settings.messages[i.name]||(this.settings.messages[i.name]={}),r.originalMessage=this.settings.messages[i.name].remote,this.settings.messages[i.name].remote=r.message,s="string"==typeof s&&{url:s}||s,r.old===e)return r.valid;r.old=e;var n=this;this.startRequest(i);var a={};return a[i.name]=e,t.ajax(t.extend(!0,{url:s,mode:"abort",port:"validate"+i.name,dataType:"json",data:a,success:function(s){n.settings.messages[i.name].remote=r.originalMessage;var a=s===!0||"true"===s;if(a){var u=n.formSubmitted;n.prepareElement(i),n.formSubmitted=u,n.successList.push(i),delete n.invalid[i.name],n.showErrors()}else{var o={},l=s||n.defaultMessage(i,"remote");o[i.name]=r.message=t.isFunction(l)?l(e):l,n.invalid[i.name]=!0,n.showErrors(o)}r.valid=a,n.stopRequest(i,a)}},s)),"pending"}}}),t.format=t.validator.format})(jQuery),function(t){var e={};if(t.ajaxPrefilter)t.ajaxPrefilter(function(t,i,s){var r=t.port;"abort"===t.mode&&(e[r]&&e[r].abort(),e[r]=s)});else{var i=t.ajax;t.ajax=function(s){var r=("mode"in s?s:t.ajaxSettings).mode,n=("port"in s?s:t.ajaxSettings).port;return"abort"===r?(e[n]&&e[n].abort(),e[n]=i.apply(this,arguments),e[n]):i.apply(this,arguments)}}}(jQuery),function(t){t.extend(t.fn,{validateDelegate:function(e,i,s){return this.bind(i,function(i){var r=t(i.target);return r.is(e)?s.apply(r,arguments):void 0})}})}(jQuery); -------------------------------------------------------------------------------- /RoslinqTestTarget/Scripts/jquery.validate.unobtrusive.min.js: -------------------------------------------------------------------------------- 1 | /* NUGET: BEGIN LICENSE TEXT 2 | * 3 | * Microsoft grants you the right to use these script files for the sole 4 | * purpose of either: (i) interacting through your browser with the Microsoft 5 | * website or online service, subject to the applicable licensing or use 6 | * terms; or (ii) using the files as included with a Microsoft product subject 7 | * to that product's license terms. Microsoft reserves all other rights to the 8 | * files not expressly granted by Microsoft, whether by implication, estoppel 9 | * or otherwise. Insofar as a script file is dual licensed under GPL, 10 | * Microsoft neither took the code under GPL nor distributes it thereunder but 11 | * under the terms set out in this paragraph. All notices and licenses 12 | * below are for informational purposes only. 13 | * 14 | * NUGET: END LICENSE TEXT */ 15 | /* 16 | ** Unobtrusive validation support library for jQuery and jQuery Validate 17 | ** Copyright (C) Microsoft Corporation. All rights reserved. 18 | */ 19 | (function(a){var d=a.validator,b,e="unobtrusiveValidation";function c(a,b,c){a.rules[b]=c;if(a.message)a.messages[b]=a.message}function j(a){return a.replace(/^\s+|\s+$/g,"").split(/\s*,\s*/g)}function f(a){return a.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g,"\\$1")}function h(a){return a.substr(0,a.lastIndexOf(".")+1)}function g(a,b){if(a.indexOf("*.")===0)a=a.replace("*.",b);return a}function m(c,e){var b=a(this).find("[data-valmsg-for='"+f(e[0].name)+"']"),d=b.attr("data-valmsg-replace"),g=d?a.parseJSON(d)!==false:null;b.removeClass("field-validation-valid").addClass("field-validation-error");c.data("unobtrusiveContainer",b);if(g){b.empty();c.removeClass("input-validation-error").appendTo(b)}else c.hide()}function l(e,d){var c=a(this).find("[data-valmsg-summary=true]"),b=c.find("ul");if(b&&b.length&&d.errorList.length){b.empty();c.addClass("validation-summary-errors").removeClass("validation-summary-valid");a.each(d.errorList,function(){a("
  • ").html(this.message).appendTo(b)})}}function k(d){var b=d.data("unobtrusiveContainer"),c=b.attr("data-valmsg-replace"),e=c?a.parseJSON(c):null;if(b){b.addClass("field-validation-valid").removeClass("field-validation-error");d.removeData("unobtrusiveContainer");e&&b.empty()}}function n(){var b=a(this),c="__jquery_unobtrusive_validation_form_reset";if(b.data(c))return;b.data(c,true);try{b.data("validator").resetForm()}finally{b.removeData(c)}b.find(".validation-summary-errors").addClass("validation-summary-valid").removeClass("validation-summary-errors");b.find(".field-validation-error").addClass("field-validation-valid").removeClass("field-validation-error").removeData("unobtrusiveContainer").find(">*").removeData("unobtrusiveContainer")}function i(b){var c=a(b),f=c.data(e),i=a.proxy(n,b),g=d.unobtrusive.options||{},h=function(e,d){var c=g[e];c&&a.isFunction(c)&&c.apply(b,d)};if(!f){f={options:{errorClass:g.errorClass||"input-validation-error",errorElement:g.errorElement||"span",errorPlacement:function(){m.apply(b,arguments);h("errorPlacement",arguments)},invalidHandler:function(){l.apply(b,arguments);h("invalidHandler",arguments)},messages:{},rules:{},success:function(){k.apply(b,arguments);h("success",arguments)}},attachValidation:function(){c.off("reset."+e,i).on("reset."+e,i).validate(this.options)},validate:function(){c.validate();return c.valid()}};c.data(e,f)}return f}d.unobtrusive={adapters:[],parseElement:function(b,h){var d=a(b),f=d.parents("form")[0],c,e,g;if(!f)return;c=i(f);c.options.rules[b.name]=e={};c.options.messages[b.name]=g={};a.each(this.adapters,function(){var c="data-val-"+this.name,i=d.attr(c),h={};if(i!==undefined){c+="-";a.each(this.params,function(){h[this]=d.attr(c+this)});this.adapt({element:b,form:f,message:i,params:h,rules:e,messages:g})}});a.extend(e,{__dummy__:true});!h&&c.attachValidation()},parse:function(c){var b=a(c),e=b.parents().addBack().filter("form").add(b.find("form")).has("[data-val=true]");b.find("[data-val=true]").each(function(){d.unobtrusive.parseElement(this,true)});e.each(function(){var a=i(this);a&&a.attachValidation()})}};b=d.unobtrusive.adapters;b.add=function(c,a,b){if(!b){b=a;a=[]}this.push({name:c,params:a,adapt:b});return this};b.addBool=function(a,b){return this.add(a,function(d){c(d,b||a,true)})};b.addMinMax=function(e,g,f,a,d,b){return this.add(e,[d||"min",b||"max"],function(b){var e=b.params.min,d=b.params.max;if(e&&d)c(b,a,[e,d]);else if(e)c(b,g,e);else d&&c(b,f,d)})};b.addSingleVal=function(a,b,d){return this.add(a,[b||"val"],function(e){c(e,d||a,e.params[b])})};d.addMethod("__dummy__",function(){return true});d.addMethod("regex",function(b,c,d){var a;if(this.optional(c))return true;a=(new RegExp(d)).exec(b);return a&&a.index===0&&a[0].length===b.length});d.addMethod("nonalphamin",function(c,d,b){var a;if(b){a=c.match(/\W/g);a=a&&a.length>=b}return a});if(d.methods.extension){b.addSingleVal("accept","mimtype");b.addSingleVal("extension","extension")}else b.addSingleVal("extension","extension","accept");b.addSingleVal("regex","pattern");b.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url");b.addMinMax("length","minlength","maxlength","rangelength").addMinMax("range","min","max","range");b.addMinMax("minlength","minlength").addMinMax("maxlength","minlength","maxlength");b.add("equalto",["other"],function(b){var i=h(b.element.name),j=b.params.other,d=g(j,i),e=a(b.form).find(":input").filter("[name='"+f(d)+"']")[0];c(b,"equalTo",e)});b.add("required",function(a){(a.element.tagName.toUpperCase()!=="INPUT"||a.element.type.toUpperCase()!=="CHECKBOX")&&c(a,"required",true)});b.add("remote",["url","type","additionalfields"],function(b){var d={url:b.params.url,type:b.params.type||"GET",data:{}},e=h(b.element.name);a.each(j(b.params.additionalfields||b.element.name),function(i,h){var c=g(h,e);d.data[c]=function(){var d=a(b.form).find(":input").filter("[name='"+f(c)+"']");return d.is(":checkbox")?d.filter(":checked").val()||d.filter(":hidden").val()||"":d.is(":radio")?d.filter(":checked").val()||"":d.val()}});c(b,"remote",d)});b.add("password",["min","nonalphamin","regex"],function(a){a.params.min&&c(a,"minlength",a.params.min);a.params.nonalphamin&&c(a,"nonalphamin",a.params.nonalphamin);a.params.regex&&c(a,"regex",a.params.regex)});a(function(){d.unobtrusive.parse(document)})})(jQuery); -------------------------------------------------------------------------------- /RoslinqTestTarget/Scripts/respond.js: -------------------------------------------------------------------------------- 1 | /* NUGET: BEGIN LICENSE TEXT 2 | * 3 | * Microsoft grants you the right to use these script files for the sole 4 | * purpose of either: (i) interacting through your browser with the Microsoft 5 | * website or online service, subject to the applicable licensing or use 6 | * terms; or (ii) using the files as included with a Microsoft product subject 7 | * to that product's license terms. Microsoft reserves all other rights to the 8 | * files not expressly granted by Microsoft, whether by implication, estoppel 9 | * or otherwise. Insofar as a script file is dual licensed under GPL, 10 | * Microsoft neither took the code under GPL nor distributes it thereunder but 11 | * under the terms set out in this paragraph. All notices and licenses 12 | * below are for informational purposes only. 13 | * 14 | * NUGET: END LICENSE TEXT */ 15 | /*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */ 16 | /*! NOTE: If you're already including a window.matchMedia polyfill via Modernizr or otherwise, you don't need this part */ 17 | window.matchMedia = window.matchMedia || (function(doc, undefined){ 18 | 19 | var bool, 20 | docElem = doc.documentElement, 21 | refNode = docElem.firstElementChild || docElem.firstChild, 22 | // fakeBody required for 23 | fakeBody = doc.createElement('body'), 24 | div = doc.createElement('div'); 25 | 26 | div.id = 'mq-test-1'; 27 | div.style.cssText = "position:absolute;top:-100em"; 28 | fakeBody.style.background = "none"; 29 | fakeBody.appendChild(div); 30 | 31 | return function(q){ 32 | 33 | div.innerHTML = '­'; 34 | 35 | docElem.insertBefore(fakeBody, refNode); 36 | bool = div.offsetWidth == 42; 37 | docElem.removeChild(fakeBody); 38 | 39 | return { matches: bool, media: q }; 40 | }; 41 | 42 | })(document); 43 | 44 | 45 | 46 | 47 | /*! Respond.js v1.2.0: min/max-width media query polyfill. (c) Scott Jehl. MIT/GPLv2 Lic. j.mp/respondjs */ 48 | (function( win ){ 49 | //exposed namespace 50 | win.respond = {}; 51 | 52 | //define update even in native-mq-supporting browsers, to avoid errors 53 | respond.update = function(){}; 54 | 55 | //expose media query support flag for external use 56 | respond.mediaQueriesSupported = win.matchMedia && win.matchMedia( "only all" ).matches; 57 | 58 | //if media queries are supported, exit here 59 | if( respond.mediaQueriesSupported ){ return; } 60 | 61 | //define vars 62 | var doc = win.document, 63 | docElem = doc.documentElement, 64 | mediastyles = [], 65 | rules = [], 66 | appendedEls = [], 67 | parsedSheets = {}, 68 | resizeThrottle = 30, 69 | head = doc.getElementsByTagName( "head" )[0] || docElem, 70 | base = doc.getElementsByTagName( "base" )[0], 71 | links = head.getElementsByTagName( "link" ), 72 | requestQueue = [], 73 | 74 | //loop stylesheets, send text content to translate 75 | ripCSS = function(){ 76 | var sheets = links, 77 | sl = sheets.length, 78 | i = 0, 79 | //vars for loop: 80 | sheet, href, media, isCSS; 81 | 82 | for( ; i < sl; i++ ){ 83 | sheet = sheets[ i ], 84 | href = sheet.href, 85 | media = sheet.media, 86 | isCSS = sheet.rel && sheet.rel.toLowerCase() === "stylesheet"; 87 | 88 | //only links plz and prevent re-parsing 89 | if( !!href && isCSS && !parsedSheets[ href ] ){ 90 | // selectivizr exposes css through the rawCssText expando 91 | if (sheet.styleSheet && sheet.styleSheet.rawCssText) { 92 | translate( sheet.styleSheet.rawCssText, href, media ); 93 | parsedSheets[ href ] = true; 94 | } else { 95 | if( (!/^([a-zA-Z:]*\/\/)/.test( href ) && !base) 96 | || href.replace( RegExp.$1, "" ).split( "/" )[0] === win.location.host ){ 97 | requestQueue.push( { 98 | href: href, 99 | media: media 100 | } ); 101 | } 102 | } 103 | } 104 | } 105 | makeRequests(); 106 | }, 107 | 108 | //recurse through request queue, get css text 109 | makeRequests = function(){ 110 | if( requestQueue.length ){ 111 | var thisRequest = requestQueue.shift(); 112 | 113 | ajax( thisRequest.href, function( styles ){ 114 | translate( styles, thisRequest.href, thisRequest.media ); 115 | parsedSheets[ thisRequest.href ] = true; 116 | makeRequests(); 117 | } ); 118 | } 119 | }, 120 | 121 | //find media blocks in css text, convert to style blocks 122 | translate = function( styles, href, media ){ 123 | var qs = styles.match( /@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi ), 124 | ql = qs && qs.length || 0, 125 | //try to get CSS path 126 | href = href.substring( 0, href.lastIndexOf( "/" )), 127 | repUrls = function( css ){ 128 | return css.replace( /(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g, "$1" + href + "$2$3" ); 129 | }, 130 | useMedia = !ql && media, 131 | //vars used in loop 132 | i = 0, 133 | j, fullq, thisq, eachq, eql; 134 | 135 | //if path exists, tack on trailing slash 136 | if( href.length ){ href += "/"; } 137 | 138 | //if no internal queries exist, but media attr does, use that 139 | //note: this currently lacks support for situations where a media attr is specified on a link AND 140 | //its associated stylesheet has internal CSS media queries. 141 | //In those cases, the media attribute will currently be ignored. 142 | if( useMedia ){ 143 | ql = 1; 144 | } 145 | 146 | 147 | for( ; i < ql; i++ ){ 148 | j = 0; 149 | 150 | //media attr 151 | if( useMedia ){ 152 | fullq = media; 153 | rules.push( repUrls( styles ) ); 154 | } 155 | //parse for styles 156 | else{ 157 | fullq = qs[ i ].match( /@media *([^\{]+)\{([\S\s]+?)$/ ) && RegExp.$1; 158 | rules.push( RegExp.$2 && repUrls( RegExp.$2 ) ); 159 | } 160 | 161 | eachq = fullq.split( "," ); 162 | eql = eachq.length; 163 | 164 | for( ; j < eql; j++ ){ 165 | thisq = eachq[ j ]; 166 | mediastyles.push( { 167 | media : thisq.split( "(" )[ 0 ].match( /(only\s+)?([a-zA-Z]+)\s?/ ) && RegExp.$2 || "all", 168 | rules : rules.length - 1, 169 | hasquery: thisq.indexOf("(") > -1, 170 | minw : thisq.match( /\(min\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/ ) && parseFloat( RegExp.$1 ) + ( RegExp.$2 || "" ), 171 | maxw : thisq.match( /\(max\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/ ) && parseFloat( RegExp.$1 ) + ( RegExp.$2 || "" ) 172 | } ); 173 | } 174 | } 175 | 176 | applyMedia(); 177 | }, 178 | 179 | lastCall, 180 | 181 | resizeDefer, 182 | 183 | // returns the value of 1em in pixels 184 | getEmValue = function() { 185 | var ret, 186 | div = doc.createElement('div'), 187 | body = doc.body, 188 | fakeUsed = false; 189 | 190 | div.style.cssText = "position:absolute;font-size:1em;width:1em"; 191 | 192 | if( !body ){ 193 | body = fakeUsed = doc.createElement( "body" ); 194 | body.style.background = "none"; 195 | } 196 | 197 | body.appendChild( div ); 198 | 199 | docElem.insertBefore( body, docElem.firstChild ); 200 | 201 | ret = div.offsetWidth; 202 | 203 | if( fakeUsed ){ 204 | docElem.removeChild( body ); 205 | } 206 | else { 207 | body.removeChild( div ); 208 | } 209 | 210 | //also update eminpx before returning 211 | ret = eminpx = parseFloat(ret); 212 | 213 | return ret; 214 | }, 215 | 216 | //cached container for 1em value, populated the first time it's needed 217 | eminpx, 218 | 219 | //enable/disable styles 220 | applyMedia = function( fromResize ){ 221 | var name = "clientWidth", 222 | docElemProp = docElem[ name ], 223 | currWidth = doc.compatMode === "CSS1Compat" && docElemProp || doc.body[ name ] || docElemProp, 224 | styleBlocks = {}, 225 | lastLink = links[ links.length-1 ], 226 | now = (new Date()).getTime(); 227 | 228 | //throttle resize calls 229 | if( fromResize && lastCall && now - lastCall < resizeThrottle ){ 230 | clearTimeout( resizeDefer ); 231 | resizeDefer = setTimeout( applyMedia, resizeThrottle ); 232 | return; 233 | } 234 | else { 235 | lastCall = now; 236 | } 237 | 238 | for( var i in mediastyles ){ 239 | var thisstyle = mediastyles[ i ], 240 | min = thisstyle.minw, 241 | max = thisstyle.maxw, 242 | minnull = min === null, 243 | maxnull = max === null, 244 | em = "em"; 245 | 246 | if( !!min ){ 247 | min = parseFloat( min ) * ( min.indexOf( em ) > -1 ? ( eminpx || getEmValue() ) : 1 ); 248 | } 249 | if( !!max ){ 250 | max = parseFloat( max ) * ( max.indexOf( em ) > -1 ? ( eminpx || getEmValue() ) : 1 ); 251 | } 252 | 253 | // if there's no media query at all (the () part), or min or max is not null, and if either is present, they're true 254 | if( !thisstyle.hasquery || ( !minnull || !maxnull ) && ( minnull || currWidth >= min ) && ( maxnull || currWidth <= max ) ){ 255 | if( !styleBlocks[ thisstyle.media ] ){ 256 | styleBlocks[ thisstyle.media ] = []; 257 | } 258 | styleBlocks[ thisstyle.media ].push( rules[ thisstyle.rules ] ); 259 | } 260 | } 261 | 262 | //remove any existing respond style element(s) 263 | for( var i in appendedEls ){ 264 | if( appendedEls[ i ] && appendedEls[ i ].parentNode === head ){ 265 | head.removeChild( appendedEls[ i ] ); 266 | } 267 | } 268 | 269 | //inject active styles, grouped by media type 270 | for( var i in styleBlocks ){ 271 | var ss = doc.createElement( "style" ), 272 | css = styleBlocks[ i ].join( "\n" ); 273 | 274 | ss.type = "text/css"; 275 | ss.media = i; 276 | 277 | //originally, ss was appended to a documentFragment and sheets were appended in bulk. 278 | //this caused crashes in IE in a number of circumstances, such as when the HTML element had a bg image set, so appending beforehand seems best. Thanks to @dvelyk for the initial research on this one! 279 | head.insertBefore( ss, lastLink.nextSibling ); 280 | 281 | if ( ss.styleSheet ){ 282 | ss.styleSheet.cssText = css; 283 | } 284 | else { 285 | ss.appendChild( doc.createTextNode( css ) ); 286 | } 287 | 288 | //push to appendedEls to track for later removal 289 | appendedEls.push( ss ); 290 | } 291 | }, 292 | //tweaked Ajax functions from Quirksmode 293 | ajax = function( url, callback ) { 294 | var req = xmlHttp(); 295 | if (!req){ 296 | return; 297 | } 298 | req.open( "GET", url, true ); 299 | req.onreadystatechange = function () { 300 | if ( req.readyState != 4 || req.status != 200 && req.status != 304 ){ 301 | return; 302 | } 303 | callback( req.responseText ); 304 | } 305 | if ( req.readyState == 4 ){ 306 | return; 307 | } 308 | req.send( null ); 309 | }, 310 | //define ajax obj 311 | xmlHttp = (function() { 312 | var xmlhttpmethod = false; 313 | try { 314 | xmlhttpmethod = new XMLHttpRequest(); 315 | } 316 | catch( e ){ 317 | xmlhttpmethod = new ActiveXObject( "Microsoft.XMLHTTP" ); 318 | } 319 | return function(){ 320 | return xmlhttpmethod; 321 | }; 322 | })(); 323 | 324 | //translate CSS 325 | ripCSS(); 326 | 327 | //expose update for re-running respond later on 328 | respond.update = ripCSS; 329 | 330 | //adjust on resize 331 | function callMedia(){ 332 | applyMedia( true ); 333 | } 334 | if( win.addEventListener ){ 335 | win.addEventListener( "resize", callMedia, false ); 336 | } 337 | else if( win.attachEvent ){ 338 | win.attachEvent( "onresize", callMedia ); 339 | } 340 | })(this); 341 | -------------------------------------------------------------------------------- /RoslinqTestTarget/Scripts/respond.min.js: -------------------------------------------------------------------------------- 1 | /* NUGET: BEGIN LICENSE TEXT 2 | * 3 | * Microsoft grants you the right to use these script files for the sole 4 | * purpose of either: (i) interacting through your browser with the Microsoft 5 | * website or online service, subject to the applicable licensing or use 6 | * terms; or (ii) using the files as included with a Microsoft product subject 7 | * to that product's license terms. Microsoft reserves all other rights to the 8 | * files not expressly granted by Microsoft, whether by implication, estoppel 9 | * or otherwise. Insofar as a script file is dual licensed under GPL, 10 | * Microsoft neither took the code under GPL nor distributes it thereunder but 11 | * under the terms set out in this paragraph. All notices and licenses 12 | * below are for informational purposes only. 13 | * 14 | * NUGET: END LICENSE TEXT */ 15 | /*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */ 16 | /*! NOTE: If you're already including a window.matchMedia polyfill via Modernizr or otherwise, you don't need this part */ 17 | window.matchMedia=window.matchMedia||(function(e,f){var c,a=e.documentElement,b=a.firstElementChild||a.firstChild,d=e.createElement("body"),g=e.createElement("div");g.id="mq-test-1";g.style.cssText="position:absolute;top:-100em";d.style.background="none";d.appendChild(g);return function(h){g.innerHTML='­';a.insertBefore(d,b);c=g.offsetWidth==42;a.removeChild(d);return{matches:c,media:h}}})(document); 18 | 19 | /*! Respond.js v1.2.0: min/max-width media query polyfill. (c) Scott Jehl. MIT/GPLv2 Lic. j.mp/respondjs */ 20 | (function(e){e.respond={};respond.update=function(){};respond.mediaQueriesSupported=e.matchMedia&&e.matchMedia("only all").matches;if(respond.mediaQueriesSupported){return}var w=e.document,s=w.documentElement,i=[],k=[],q=[],o={},h=30,f=w.getElementsByTagName("head")[0]||s,g=w.getElementsByTagName("base")[0],b=f.getElementsByTagName("link"),d=[],a=function(){var D=b,y=D.length,B=0,A,z,C,x;for(;B-1,minw:F.match(/\(min\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:F.match(/\(max\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}}j()},l,r,v=function(){var z,A=w.createElement("div"),x=w.body,y=false;A.style.cssText="position:absolute;font-size:1em;width:1em";if(!x){x=y=w.createElement("body");x.style.background="none"}x.appendChild(A);s.insertBefore(x,s.firstChild);z=A.offsetWidth;if(y){s.removeChild(x)}else{x.removeChild(A)}z=p=parseFloat(z);return z},p,j=function(I){var x="clientWidth",B=s[x],H=w.compatMode==="CSS1Compat"&&B||w.body[x]||B,D={},G=b[b.length-1],z=(new Date()).getTime();if(I&&l&&z-l-1?(p||v()):1)}if(!!J){J=parseFloat(J)*(J.indexOf(y)>-1?(p||v()):1)}if(!K.hasquery||(!A||!L)&&(A||H>=C)&&(L||H<=J)){if(!D[K.media]){D[K.media]=[]}D[K.media].push(k[K.rules])}}for(var E in q){if(q[E]&&q[E].parentNode===f){f.removeChild(q[E])}}for(var E in D){var M=w.createElement("style"),F=D[E].join("\n");M.type="text/css";M.media=E;f.insertBefore(M,G.nextSibling);if(M.styleSheet){M.styleSheet.cssText=F}else{M.appendChild(w.createTextNode(F))}q.push(M)}},n=function(x,z){var y=c();if(!y){return}y.open("GET",x,true);y.onreadystatechange=function(){if(y.readyState!=4||y.status!=200&&y.status!=304){return}z(y.responseText)};if(y.readyState==4){return}y.send(null)},c=(function(){var x=false;try{x=new XMLHttpRequest()}catch(y){x=new ActiveXObject("Microsoft.XMLHTTP")}return function(){return x}})();a();respond.update=a;function t(){j(true)}if(e.addEventListener){e.addEventListener("resize",t,false)}else{if(e.attachEvent){e.attachEvent("onresize",t)}}})(this); -------------------------------------------------------------------------------- /RoslinqTestTarget/Views/Home/About.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "About"; 3 | } 4 |

    @ViewBag.Title.

    5 |

    @ViewBag.Message

    6 | 7 |

    Use this area to provide additional information.

    8 | -------------------------------------------------------------------------------- /RoslinqTestTarget/Views/Home/Contact.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "Contact"; 3 | } 4 |

    @ViewBag.Title.

    5 |

    @ViewBag.Message

    6 | 7 |
    8 | One Microsoft Way
    9 | Redmond, WA 98052-6399
    10 | P: 11 | 425.555.0100 12 |
    13 | 14 |
    15 | Support: Support@example.com
    16 | Marketing: Marketing@example.com 17 |
    -------------------------------------------------------------------------------- /RoslinqTestTarget/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "Home Page"; 3 | } 4 | 5 |
    6 |

    ASP.NET

    7 |

    ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.

    8 |

    Learn more »

    9 |
    10 | 11 |
    12 |
    13 |

    Getting started

    14 |

    15 | ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that 16 | enables a clean separation of concerns and gives you full control over markup 17 | for enjoyable, agile development. 18 |

    19 |

    Learn more »

    20 |
    21 |
    22 |

    Get more libraries

    23 |

    NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.

    24 |

    Learn more »

    25 |
    26 |
    27 |

    Web Hosting

    28 |

    You can easily find a web hosting company that offers the right mix of features and price for your applications.

    29 |

    Learn more »

    30 |
    31 |
    -------------------------------------------------------------------------------- /RoslinqTestTarget/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = null; 3 | } 4 | 5 | 6 | 7 | 8 | 9 | Error 10 | 11 | 12 |
    13 |

    Error.

    14 |

    An error occurred while processing your request.

    15 |
    16 | 17 | 18 | -------------------------------------------------------------------------------- /RoslinqTestTarget/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewBag.Title - My ASP.NET Application 7 | @Styles.Render("~/Content/css") 8 | @Scripts.Render("~/bundles/modernizr") 9 | 10 | 11 | 30 |
    31 | @RenderBody() 32 |
    33 |
    34 |

    © @DateTime.Now.Year - My ASP.NET Application

    35 |
    36 |
    37 | 38 | @Scripts.Render("~/bundles/jquery") 39 | @Scripts.Render("~/bundles/bootstrap") 40 | @RenderSection("scripts", required: false) 41 | 42 | 43 | -------------------------------------------------------------------------------- /RoslinqTestTarget/Views/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 |
    7 |
    8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /RoslinqTestTarget/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "~/Views/Shared/_Layout.cshtml"; 3 | } 4 | -------------------------------------------------------------------------------- /RoslinqTestTarget/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /RoslinqTestTarget/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /RoslinqTestTarget/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /RoslinqTestTarget/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benetkiewicz/Roslinq/41e1159860632055e0b5891bc5921a1b8e49007a/RoslinqTestTarget/favicon.ico -------------------------------------------------------------------------------- /RoslinqTestTarget/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | --------------------------------------------------------------------------------