public void Setup() { allocator = new BufferAllocator(); var record = new EventRecordBuilder(allocator); record.Record.EventHeader.ProviderId = new Guid("6D35524C-C587-476A-92D3-F333D223BDCF"); record.Record.EventHeader.EventDescriptor.Id = 1; record.AddArg(32); var info = new TraceEventInfoBuilder(allocator); info.EventMessage = "Foo %1 Bar"; info.PropertyCount = 1; info.TopLevelPropertyCount = 1; info.EventPropertyInfos = new[] { new EVENT_PROPERTY_INFO { InType = TDH_IN_TYPE.INT32, OutType = TDH_OUT_TYPE.INT, countAndCountPropertyIndex = 1, lengthAndLengthPropertyIndex = 4 } }; recordPtr = record.Build(); infoPtr = info.Build(); var filter1 = new TraceLogFilter(); for (int i = 0; i < 30; ++i) { filter1.Conditions.Add( new TraceLogFilterCondition("ProviderId == {6D35524C-C587-476A-92D3-F333D223BDCF} && Id == " + (i + 2), true, FilterConditionAction.Exclude)); } var filter2 = new TraceLogFilter(); var expr = new StringBuilder(); expr.Append("ProviderId == {6D35524C-C587-476A-92D3-F333D223BDCF} && ("); for (int i = 0; i < 30; ++i) { if (i > 0) { expr.Append(" || "); } expr.Append($"Id == {i + 2}"); } expr.Append(")"); filter2.Conditions.Add( new TraceLogFilterCondition(expr.ToString(), true, FilterConditionAction.Exclude)); var filter3 = new TraceLogFilter(); filter3.Conditions.Add( new TraceLogFilterCondition("ProviderId == {6D35524C-C587-476A-92D3-F333D223BDCF} && Id != 1", true, FilterConditionAction.Exclude)); filterPredicate1 = filter1.CreatePredicate(); filterPredicate2 = filter2.CreatePredicate(); filterPredicate3 = filter3.CreatePredicate(); }
public unsafe void Create(string providerId, ushort id, bool expected) { var builder = TraceLogFilterBuilder.Instance; var filter = new TraceLogFilter(); //filter.Conditions.Add(new TraceLogFilterCondition( // builder.ProviderId, true, FilterRelationKind.NotEqual, FilterConditionAction.Exclude, new Guid("E53CD252-C0DA-49DD-93B0-28744D498D0F"))); //filter.Conditions.Add(new TraceLogFilterCondition( // builder.Id, true, FilterRelationKind.Equal, FilterConditionAction.Exclude, (ushort)1)); filter.Conditions.Add(new TraceLogFilterCondition( "ProviderId == {FF4B1F18-0D41-4DE6-A576-7FD58477A869} || id != 1", true, FilterConditionAction.Include)); var record = new EVENT_RECORD(); var tei = new TRACE_EVENT_INFO(); var teiSize = new UIntPtr((uint)Marshal.SizeOf <TRACE_EVENT_INFO>()); record.EventHeader.ProviderId = new Guid(providerId); record.EventHeader.EventDescriptor.Id = id; Assert.Equal(expected, filter.CreatePredicate()(new IntPtr(&record), new IntPtr(&tei), teiSize)); }