Prexonite, a .NET hosted scripting language with a focus on meta-programming and embedded DSLs
0

Configure Feed

Select the types of activity you want to include in your feed.

Make Prexonite assembly internals available to PrexoniteTests.

Christian Klauser (Feb 10, 2013, 8:34 PM +0100) 598270da 271796fa

+159 -82
+20
Prexonite/Compiler/Build/Internal/DefaultModuleTarget.cs
··· 40 40 _isSuccessful = exception == null && (_messages == null || _messages.All(m => m.Severity != MessageSeverity.Error)); 41 41 } 42 42 43 + [CanBeNull] 44 + private static Exception _createAggregateException(Exception[] aggregateExceptions) 45 + { 46 + Exception aggregateException; 47 + if (aggregateExceptions.Length == 1) 48 + aggregateException = aggregateExceptions[0]; 49 + else if (aggregateExceptions.Length > 0) 50 + aggregateException = new AggregateException(aggregateExceptions); 51 + else 52 + aggregateException = null; 53 + return aggregateException; 54 + } 55 + 56 + internal static ITarget _FromLoader(Loader loader, Exception[] exceptions = null, IEnumerable<Message> additionalMessages = null) 57 + { 58 + return _FromLoader(loader, 59 + exceptions == null ? null : _createAggregateException(exceptions), 60 + additionalMessages); 61 + } 62 + 43 63 internal static ITarget _FromLoader(Loader loader, Exception exception = null, IEnumerable<Message> additionalMessages = null) 44 64 { 45 65 if (loader == null)
+41 -61
Prexonite/Compiler/Build/ManualTargetDescription.cs
··· 53 53 54 54 public Task<ITarget> BuildAsync(IBuildEnvironment build, IDictionary<ModuleName, Task<ITarget>> dependencies, CancellationToken token) 55 55 { 56 - return Task.Factory.StartNew(() => 57 - { 58 - var ldr = build.CreateLoader(new LoaderOptions(null, null)); 59 - 60 - var aggregateMessages = dependencies.Values 61 - .SelectMany(t => t.Result.Messages); 62 - var aggregateExceptions = dependencies.Values 63 - .Select(t => t.Result.Exception) 64 - .Where(e => e != null); 65 - if (dependencies.Values.All(t => t.Result.IsSuccessful)) 56 + return Task.Factory.StartNew( 57 + () => 66 58 { 67 - try 59 + var ldr = build.CreateLoader(new LoaderOptions(null, null)); 60 + 61 + var aggregateMessages = dependencies.Values 62 + .SelectMany(t => t.Result.Messages); 63 + var aggregateExceptions = dependencies.Values 64 + .Select(t => t.Result.Exception) 65 + .Where(e => e != null); 66 + if (dependencies.Values.All(t => t.Result.IsSuccessful)) 68 67 { 69 - TextReader reader; 70 - if (!_source.TryOpen(out reader)) 71 - throw new BuildFailureException(this, 72 - string.Format("The source for target {0} could not be opened.", Name), 73 - Enumerable.Empty<Message>()); 74 - using (reader) 68 + try 75 69 { 76 - token.ThrowIfCancellationRequested(); 77 - Plan.Trace.TraceEvent(TraceEventType.Information, 0, "Building {0}.", this); 78 - Trace.CorrelationManager.StartLogicalOperation("Build"); 79 - ldr.LoadFromReader(reader, _fileName); 80 - Trace.CorrelationManager.StopLogicalOperation(); 81 - Plan.Trace.TraceEvent(TraceEventType.Verbose, 0, "Done with building {0}, wrapping result in target.", this); 82 - } 83 - 84 - // ReSharper disable PossibleMultipleEnumeration 85 - return _createTargetFromLoader(ldr, aggregateExceptions.ToArray(), aggregateMessages); 70 + TextReader reader; 71 + if (!_source.TryOpen(out reader)) 72 + throw new BuildFailureException(this, 73 + string.Format("The source for target {0} could not be opened.", Name), 74 + Enumerable.Empty<Message>()); 75 + using (reader) 76 + { 77 + token.ThrowIfCancellationRequested(); 78 + Plan.Trace.TraceEvent(TraceEventType.Information, 0, "Building {0}.", this); 79 + Trace.CorrelationManager.StartLogicalOperation("Build"); 80 + ldr.LoadFromReader(reader, _fileName); 81 + Trace.CorrelationManager.StopLogicalOperation(); 82 + Plan.Trace.TraceEvent(TraceEventType.Verbose, 0, "Done with building {0}, wrapping result in target.", this); 83 + } 86 84 85 + // ReSharper disable PossibleMultipleEnumeration 86 + return DefaultModuleTarget._FromLoader(ldr, aggregateExceptions.ToArray(), aggregateMessages); 87 + } 88 + catch (Exception e) 89 + { 90 + return DefaultModuleTarget._FromLoader(ldr,aggregateExceptions.Append(e).ToArray(), 91 + aggregateMessages); 92 + // ReSharper restore PossibleMultipleEnumeration 93 + } 87 94 } 88 - catch (Exception e) 95 + else 89 96 { 90 - return DefaultModuleTarget._FromLoader(ldr, 91 - _createAggregateException(aggregateExceptions.Append(e).ToArray()), 92 - aggregateMessages); 93 - // ReSharper restore PossibleMultipleEnumeration 97 + Plan.Trace.TraceEvent(TraceEventType.Error, 0, 98 + "Not all dependencies of {0} were built successfully. Waiting for other dependencies to finish and then return a failed target.", 99 + this); 100 + Task.WaitAll(dependencies.Values.ToArray<Task>()); 101 + return DefaultModuleTarget._FromLoader(ldr, aggregateExceptions.ToArray(), aggregateMessages); 94 102 } 95 - } 96 - else 97 - { 98 - Plan.Trace.TraceEvent(TraceEventType.Error, 0, "Not all dependencies of {0} were built successfully. Waiting for other dependencies to finish and then return a failed target.",this); 99 - Task.WaitAll(dependencies.Values.ToArray<Task>()); 100 - return _createTargetFromLoader(ldr, aggregateExceptions.ToArray(), aggregateMessages); 101 - } 102 - },token); 103 - } 104 - 105 - private static ITarget _createTargetFromLoader(Loader ldr, Exception[] aggregateExceptions, IEnumerable<Message> aggregateMessages) 106 - { 107 - return DefaultModuleTarget._FromLoader( 108 - ldr, 109 - _createAggregateException(aggregateExceptions), 110 - aggregateMessages); 111 - } 112 - 113 - [CanBeNull] 114 - private static Exception _createAggregateException(Exception[] aggregateExceptions) 115 - { 116 - Exception aggregateException; 117 - if (aggregateExceptions.Length == 1) 118 - aggregateException = aggregateExceptions[0]; 119 - else if (aggregateExceptions.Length > 0) 120 - aggregateException = new AggregateException(aggregateExceptions); 121 - else 122 - aggregateException = null; 123 - return aggregateException; 103 + }, token); 124 104 } 125 105 126 106 public override string ToString()
+2
Prexonite/Modular/IResourceDescriptor.cs
··· 3 3 using System.IO; 4 4 using System.Linq; 5 5 using System.Text; 6 + using System.Threading.Tasks; 6 7 7 8 namespace Prexonite.Modular 8 9 { 9 10 public interface IResourceDescriptor 10 11 { 11 12 Stream Open(); 13 + Task ExtractAsync(string destinationPath); 12 14 void Extract(string destinationPath); 13 15 } 14 16 }
Prexonite/Prexonite.pub

This is a binary file and will not be displayed.

+14 -1
Prexonite/Properties/AssemblyInfo.cs
··· 26 26 27 27 using System; 28 28 using System.Reflection; 29 + using System.Runtime.CompilerServices; 29 30 using System.Runtime.InteropServices; 30 31 31 32 // General Information about an assembly is controlled through the following ··· 60 61 61 62 [assembly: AssemblyVersion("1.2.9.0")] 62 63 [assembly: AssemblyFileVersion("1.2.9.0")] 63 - [assembly: CLSCompliant(true)] 64 + [assembly: CLSCompliant(true)] 65 + 66 + // Makes internal members of Prexonite visible to the unit testing project 67 + // PrexoniteTests. 68 + // The public key can be obtained by running 69 + // $> sn -p Prexonite.snk -t Prexonite.pub 70 + // $> sn -tp Prexonite.pub 71 + // (Both Prexonite and PrexoniteTests are signed with the same key) 72 + [assembly: InternalsVisibleTo("PrexoniteTests, PublicKey=002400000480000094000000" 73 + + "06020000002400005253413100040000010001005def07f2a41140759af9fb2bbc95134590" 74 + + "655b13d80802066631489fe40f030ef270d151f62ff968e715f08e3df0e22f8f8f587b3e90" 75 + + "28903c2ca2bd2b7b779ed0de24679aa3463cde1f484464f0af527a7443941f83ef4272e468" 76 + + "a3e8ae7f05ff7fef7b3d0f99f4f6d42a3811d0d02350d074209283f95dccd26bbb5f7d2ebc")]
PrexoniteTests/Prexonite.snk

This is a binary file and will not be displayed.

+10
PrexoniteTests/PrexoniteTests.csproj
··· 90 90 <CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules> 91 91 <Prefer32Bit>false</Prefer32Bit> 92 92 </PropertyGroup> 93 + <PropertyGroup> 94 + <SignAssembly>true</SignAssembly> 95 + </PropertyGroup> 96 + <PropertyGroup> 97 + <AssemblyOriginatorKeyFile>Prexonite.snk</AssemblyOriginatorKeyFile> 98 + </PropertyGroup> 93 99 <ItemGroup> 94 100 <Reference Include="Microsoft.CSharp" /> 95 101 <Reference Include="Moq"> ··· 176 182 <ItemGroup> 177 183 <None Include="app.config" /> 178 184 <None Include="packages.config" /> 185 + <None Include="Prexonite.snk" /> 179 186 <None Include="psr-tests\ast.test.pxs" /> 180 187 <None Include="psr-tests\find-deficiencies.pxs" /> 181 188 <None Include="psr-tests\lang-ext.test.pxs" /> ··· 195 202 <Generator>TextTemplatingFileGenerator</Generator> 196 203 <LastGenOutput>VMTestConfigurations.cs</LastGenOutput> 197 204 </None> 205 + </ItemGroup> 206 + <ItemGroup> 207 + <Folder Include="Internal\" /> 198 208 </ItemGroup> 199 209 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> 200 210 <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
+8
PrexoniteTests/Tests/Configurations/ModuleCache.cs
··· 199 199 return result; 200 200 } 201 201 202 + public static Task<ITarget> BuildAsync(string path) 203 + { 204 + EnsureFresh(); 205 + var targetModuleName = _toModuleName(path); 206 + return Cache.BuildAsync(targetModuleName, CancellationToken.None); 207 + } 208 + 202 209 public static Task<ITarget> BuildAsync(ModuleName name) 203 210 { 211 + EnsureFresh(); 204 212 _trace.TraceEvent(TraceEventType.Information, 0, "Requested asynchronous build of module {0}.", name); 205 213 return Cache.BuildAsync(name, CancellationToken.None); 206 214 }
+5
PrexoniteTests/Tests/Configurations/PsrUnitTests.cs
··· 30 30 31 31 } 32 32 }; 33 + Initialize(); 33 34 Runner.Configure(model, this); 34 35 } 35 36 ··· 135 136 136 137 } 137 138 }; 139 + Initialize(); 138 140 Runner.Configure(model, this); 139 141 } 140 142 ··· 192 194 193 195 } 194 196 }; 197 + Initialize(); 195 198 Runner.Configure(model, this); 196 199 } 197 200 ··· 350 353 351 354 } 352 355 }; 356 + Initialize(); 353 357 Runner.Configure(model, this); 354 358 } 355 359 ··· 452 456 453 457 } 454 458 }; 459 + Initialize(); 455 460 Runner.Configure(model, this); 456 461 } 457 462
+1
PrexoniteTests/Tests/Configurations/PsrUnitTests.tt
··· 54 54 <# } #> 55 55 } 56 56 }; 57 + Initialize(); 57 58 Runner.Configure(model, this); 58 59 } 59 60
+22 -2
PrexoniteTests/Tests/Configurations/UnitTestConfiguration.cs
··· 34 34 using Prexonite.Compiler.Build; 35 35 using Prexonite.Compiler.Cil; 36 36 37 + namespace PrexoniteTests.Internal 38 + { 39 + } 40 + 37 41 namespace PrexoniteTests.Tests.Configurations 38 42 { 39 43 internal abstract class UnitTestConfiguration ··· 47 51 public FromStored() 48 52 { 49 53 throw new NotSupportedException("Store round-tripping is not currently implemented."); 54 + } 55 + 56 + internal override void Configure(TestModel model, ScriptedUnitTestContainer container) 57 + { 58 + // Rewire the units under test to point to stored representations 59 + var originalUnits = model.UnitsUnderTest.ToList(); 60 + var storedNameMap = originalUnits.Select( 61 + td => 62 + { 63 + var ext = Path.GetExtension(td.ScriptName); 64 + var extLen = ext == null ? 0 : ext.Length; 65 + var baseName = td.ScriptName.Substring(td.ScriptName.Length - extLen); 66 + return string.Format("{0}~-stored{1}", baseName, ext); 67 + }); 68 + 69 + 70 + // Configure the test as per usual 71 + base.Configure(model, container); 50 72 } 51 73 52 74 public void PrepareTestCompilation(ScriptedUnitTestContainer container) ··· 99 121 internal virtual void Configure(TestModel model, ScriptedUnitTestContainer container) 100 122 // ReSharper restore InconsistentNaming 101 123 { 102 - container.Initialize(); 103 - 104 124 // describe units under test 105 125 foreach (var unit in model.UnitsUnderTest) 106 126 ModuleCache.Describe(container.Loader, unit);
+30 -15
PrexoniteTests/Tests/Configurations/VMTestConfigurations.cs
··· 61 61 } 62 62 } 63 63 64 - [TestFixture, Explicit] 64 + [TestFixture] 65 + [Explicit] 65 66 [GeneratedCode("VMTestConfiguration.tt","0.0")] 66 67 internal class ast_StoredInterpreted : Unit_ast 67 68 { ··· 75 76 } 76 77 } 77 78 78 - [TestFixture, Explicit] 79 + [TestFixture] 80 + [Explicit] 79 81 [GeneratedCode("VMTestConfiguration.tt","0.0")] 80 82 internal class ast_StoredCilStatic : Unit_ast 81 83 { ··· 90 92 } 91 93 92 94 93 - [TestFixture, Explicit] 95 + [TestFixture] 96 + [Explicit] 94 97 [GeneratedCode("VMTestConfiguration.tt","0.0")] 95 98 internal class ast_StoredCilIsolated : Unit_ast 96 99 { ··· 152 155 } 153 156 } 154 157 155 - [TestFixture, Explicit] 158 + [TestFixture] 159 + [Explicit] 156 160 [GeneratedCode("VMTestConfiguration.tt","0.0")] 157 161 internal class lang_ext_StoredInterpreted : Unit_lang_ext 158 162 { ··· 166 170 } 167 171 } 168 172 169 - [TestFixture, Explicit] 173 + [TestFixture] 174 + [Explicit] 170 175 [GeneratedCode("VMTestConfiguration.tt","0.0")] 171 176 internal class lang_ext_StoredCilStatic : Unit_lang_ext 172 177 { ··· 181 186 } 182 187 183 188 184 - [TestFixture, Explicit] 189 + [TestFixture] 190 + [Explicit] 185 191 [GeneratedCode("VMTestConfiguration.tt","0.0")] 186 192 internal class lang_ext_StoredCilIsolated : Unit_lang_ext 187 193 { ··· 243 249 } 244 250 } 245 251 246 - [TestFixture, Explicit] 252 + [TestFixture] 253 + [Explicit] 247 254 [GeneratedCode("VMTestConfiguration.tt","0.0")] 248 255 internal class macro_StoredInterpreted : Unit_macro 249 256 { ··· 257 264 } 258 265 } 259 266 260 - [TestFixture, Explicit] 267 + [TestFixture] 268 + [Explicit] 261 269 [GeneratedCode("VMTestConfiguration.tt","0.0")] 262 270 internal class macro_StoredCilStatic : Unit_macro 263 271 { ··· 272 280 } 273 281 274 282 275 - [TestFixture, Explicit] 283 + [TestFixture] 284 + [Explicit] 276 285 [GeneratedCode("VMTestConfiguration.tt","0.0")] 277 286 internal class macro_StoredCilIsolated : Unit_macro 278 287 { ··· 334 343 } 335 344 } 336 345 337 - [TestFixture, Explicit] 346 + [TestFixture] 347 + [Explicit] 338 348 [GeneratedCode("VMTestConfiguration.tt","0.0")] 339 349 internal class misc_StoredInterpreted : Unit_misc 340 350 { ··· 348 358 } 349 359 } 350 360 351 - [TestFixture, Explicit] 361 + [TestFixture] 362 + [Explicit] 352 363 [GeneratedCode("VMTestConfiguration.tt","0.0")] 353 364 internal class misc_StoredCilStatic : Unit_misc 354 365 { ··· 363 374 } 364 375 365 376 366 - [TestFixture, Explicit] 377 + [TestFixture] 378 + [Explicit] 367 379 [GeneratedCode("VMTestConfiguration.tt","0.0")] 368 380 internal class misc_StoredCilIsolated : Unit_misc 369 381 { ··· 425 437 } 426 438 } 427 439 428 - [TestFixture, Explicit] 440 + [TestFixture] 441 + [Explicit] 429 442 [GeneratedCode("VMTestConfiguration.tt","0.0")] 430 443 internal class struct_StoredInterpreted : Unit_struct 431 444 { ··· 439 452 } 440 453 } 441 454 442 - [TestFixture, Explicit] 455 + [TestFixture] 456 + [Explicit] 443 457 [GeneratedCode("VMTestConfiguration.tt","0.0")] 444 458 internal class struct_StoredCilStatic : Unit_struct 445 459 { ··· 454 468 } 455 469 456 470 457 - [TestFixture, Explicit] 471 + [TestFixture] 472 + [Explicit] 458 473 [GeneratedCode("VMTestConfiguration.tt","0.0")] 459 474 internal class struct_StoredCilIsolated : Unit_struct 460 475 {
+6 -3
PrexoniteTests/Tests/Configurations/VMTestConfigurations.tt
··· 71 71 } 72 72 } 73 73 74 - [TestFixture, Explicit] 74 + [TestFixture] 75 + [Explicit] 75 76 [GeneratedCode("VMTestConfiguration.tt","0.0")] 76 77 internal class <#=baseName#>_StoredInterpreted : <#=className#> 77 78 { ··· 85 86 } 86 87 } 87 88 88 - [TestFixture, Explicit] 89 + [TestFixture] 90 + [Explicit] 89 91 [GeneratedCode("VMTestConfiguration.tt","0.0")] 90 92 internal class <#=baseName#>_StoredCilStatic : <#=className#> 91 93 { ··· 100 102 } 101 103 102 104 103 - [TestFixture, Explicit] 105 + [TestFixture] 106 + [Explicit] 104 107 [GeneratedCode("VMTestConfiguration.tt","0.0")] 105 108 internal class <#=baseName#>_StoredCilIsolated : <#=className#> 106 109 {