public void TestCallerInfo() { var log = new LoggerResult(); // Use the caller information log.Info("#0", CallerInfo.Get()); log.Info("#1", CallerInfo.Get()); Assert.Equal(2, log.Messages.Count); Assert.NotNull(((LogMessage)log.Messages[0]).CallerInfo); Assert.Contains("TestLogger", ((LogMessage)log.Messages[0]).CallerInfo.FilePath); Assert.True(((LogMessage)log.Messages[0]).CallerInfo.LineNumber > 0); Assert.NotNull(((LogMessage)log.Messages[1]).CallerInfo); Assert.Equal(((LogMessage)log.Messages[1]).CallerInfo.LineNumber, ((LogMessage)log.Messages[0]).CallerInfo.LineNumber + 1); }
public void TestCallerInfo() { var log = new LoggerResult(); // Use the caller information log.Info("#0", CallerInfo.Get()); log.Info("#{0}", 1, CallerInfo.Get()); Assert.That(log.Messages.Count, Is.EqualTo(2)); Assert.That(((LogMessage)log.Messages[0]).CallerInfo, Is.Not.Null); Assert.That(((LogMessage)log.Messages[0]).CallerInfo.FilePath, Is.StringContaining("TestLogger")); Assert.That(((LogMessage)log.Messages[0]).CallerInfo.LineNumber, Is.GreaterThan(0)); Assert.That(((LogMessage)log.Messages[1]).CallerInfo, Is.Not.Null); Assert.That(((LogMessage)log.Messages[1]).CallerInfo.LineNumber, Is.EqualTo(((LogMessage)log.Messages[0]).CallerInfo.LineNumber + 1)); }
private void Thread_ExceptionOccur(object sender, EventArgs <Exception> e) { Log <Service> .Error(CallerInfo.Get("z:\\066B\\global2\\HeroesCode\\server\\UnifiedNetwork\\OperationService\\Service.cs", 220), "Unhandled exception", e.Value); }
public ExpressionSyntax GenerateExpression(Slot slot) { // Automatically flow to next execution slot (if it has a null name => default behavior) if (slot != null) { // 1. First check if there is a link and use its expression var sourceLink = method.Links.Values.FirstOrDefault(x => x.Target == slot); if (sourceLink != null) { ExpressionSyntax expression; // Generate code var sourceBlock = sourceLink.Source.Owner; var sourceExecutionBlock = sourceBlock as ExecutionBlock; if (sourceExecutionBlock != null) { // If block is execution block, it must have been executed in all path until now // Note: We don't care about non execution block, since we do a full expression evaluation on them. ExecutionBlockLinkState sourceExecutionState; if (!connectivityToCurrentBlock.TryGetValue(sourceExecutionBlock, out sourceExecutionState)) { sourceExecutionState = ExecutionBlockLinkState.Never; } switch (sourceExecutionState) { case ExecutionBlockLinkState.Never: Log.Error($"{slot} in block {slot.Owner} uses a value from execution block {sourceBlock}, however it is never executed. Slot will take default value instead.", CallerInfo.Get()); sourceBlock = null; break; case ExecutionBlockLinkState.Sometimes: Log.Error($"{slot} in block {slot.Owner} uses a value from execution block {sourceBlock}, however it is executed but not in all cases. Are you using result from a conditional branch? Slot will take default value instead.", CallerInfo.Get()); // Note: we still let it generate code, so that the user can also see the error in the generated source code //sourceBlock = null; break; case ExecutionBlockLinkState.Always: // We're good, this value is always defined when we reach CurrentBlock break; default: throw new ArgumentOutOfRangeException(); } } // Only proceed if sourceBlock has not been nulled by previous checks if (sourceBlock != null) { string localName; if (outputSlotLocals.TryGetValue(sourceLink.Source, out localName)) { expression = IdentifierName(localName); } else { expression = (sourceBlock as IExpressionBlock)?.GenerateExpression(this, sourceLink.Source); } if (expression != null) { // Add annotation on both source block and link (so that we can keep track of what block/link generated what source code) expression = expression.WithAdditionalAnnotations(GenerateAnnotation(sourceLink.Source.Owner), GenerateAnnotation(sourceLink)); return(expression); } } } // 2. If a custom value is set, use it if (slot.Value != null) { return(ParseExpression(slot.Value).WithAdditionalAnnotations(GenerateAnnotation(slot.Owner))); } // 3. Fallback: use slot name if (slot.Name != null) { return(IdentifierName(slot.Name).WithAdditionalAnnotations(GenerateAnnotation(slot.Owner))); } } // TODO: Issue an error Log.Error($"{slot} in block {slot?.Owner} could not be resolved.", CallerInfo.Get()); return(IdentifierName("unknown").WithAdditionalAnnotations(GenerateAnnotation(CurrentBlock))); }
public ExpressionSyntax GenerateExpression(VisualScriptCompilerContext context, Slot slot) { // TODO: Out/ref // Other cases should have been handled by context.RegisterLocalVariable during code generation // It's also possible that this block is actually not executed and used as input, so we issue a warning anyway context.Log.Error($"No value found for slot {slot}. Note that out/ref slots are not implemented yet.", CallerInfo.Get()); return(null); }
public static ComputeTextureColor GenerateMaterialTextureNode(string vfsOutputPath, string sourceTextureFile, uint textureUVSetIndex, Vector2 textureUVscaling, TextureAddressMode addressModeU, TextureAddressMode addressModeV, Logger logger) { var textureFileName = Path.GetFileNameWithoutExtension(sourceTextureFile); var url = vfsOutputPath + "_" + textureFileName; if (File.Exists(sourceTextureFile)) { if (logger != null) { logger.Warning($"The texture '{sourceTextureFile}' referenced in the mesh material can not be found on the system. Loading will probably fail at run time.", CallerInfo.Get()); } } var uvScaling = textureUVscaling; var textureName = textureFileName; var texture = AttachedReferenceManager.CreateProxyObject <Texture>(AssetId.Empty, textureName); var currentTexture = new ComputeTextureColor(texture, (TextureCoordinate)textureUVSetIndex, uvScaling, Vector2.Zero); currentTexture.AddressModeU = addressModeU; currentTexture.AddressModeV = addressModeV; return(currentTexture); }
public static ShaderClassSource GenerateTextureLayer(string vfsOutputPath, string sourceTextureFile, int textureUVSetIndex, Vector2 textureUVscaling, ref int textureCount, ParameterKey <Texture> surfaceMaterialKey, Mesh meshData, Logger logger) { ParameterKey <Texture> parameterKey; var url = vfsOutputPath + "_" + Path.GetFileNameWithoutExtension(sourceTextureFile); if (File.Exists(sourceTextureFile)) { if (logger != null) { logger.Warning($"The texture '{sourceTextureFile}' referenced in the mesh material can not be found on the system. Loading will probably fail at run time.", CallerInfo.Get()); } } parameterKey = ParameterKeys.IndexedKey(surfaceMaterialKey, textureCount++); var uvSetName = "TEXCOORD"; if (textureUVSetIndex != 0) { uvSetName += textureUVSetIndex; } //albedoMaterial->Add(gcnew ShaderClassSource("TextureStream", uvSetName, "TEXTEST" + uvSetIndex)); var uvScaling = textureUVscaling; var textureName = parameterKey.Name; var needScaling = uvScaling != Vector2.One; var currentComposition = needScaling ? new ShaderClassSource("ComputeColorTextureRepeat", textureName, uvSetName, "float2(" + uvScaling.X + ", " + uvScaling.Y + ")") : new ShaderClassSource("ComputeColorTexture", textureName, uvSetName); return(currentComposition); }