Skip to content

Commit eb5a467

Browse files
authored
Merge pull request #390 from prom-client-net/use-defines
Use accurate HAS_ITUPLE and HAS_NATIVE_SPAN defines
2 parents 9f7d8cb + 62135e2 commit eb5a467

18 files changed

Lines changed: 119 additions & 102 deletions

src/Directory.Build.props

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project>
2+
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
3+
<PropertyGroup>
4+
<TargetFrameworks>net462;net47;netstandard2.0;net8.0</TargetFrameworks>
5+
<RepositoryUrl>https://github.com/prom-client-net/prom-client</RepositoryUrl>
6+
</PropertyGroup>
7+
<PropertyGroup
8+
Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netcoreapp2.0'))
9+
OR $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net471'))
10+
OR $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netstandard2.1'))">
11+
<DefineConstants>$(DefineConstants);HAS_ITUPLE</DefineConstants>
12+
</PropertyGroup>
13+
</Project>

src/Prometheus.Client.Abstractions/CounterExtensions.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
#if NET6_0_OR_GREATER
2+
#if HAS_ITUPLE
33
using System.Runtime.CompilerServices;
44
#endif
55

@@ -48,7 +48,7 @@ public static void IncTo(this IMetricFamily<ICounter> metricFamily, double value
4848
}
4949

5050
public static void Inc<TLabels>(this IMetricFamily<ICounter, TLabels> metricFamily, double increment = 1)
51-
#if NET6_0_OR_GREATER
51+
#if HAS_ITUPLE
5252
where TLabels : struct, ITuple, IEquatable<TLabels>
5353
#else
5454
where TLabels : struct, IEquatable<TLabels>
@@ -58,7 +58,7 @@ public static void Inc<TLabels>(this IMetricFamily<ICounter, TLabels> metricFami
5858
}
5959

6060
public static void Inc<TLabels>(this IMetricFamily<ICounter, TLabels> metricFamily, double increment, long timestamp)
61-
#if NET6_0_OR_GREATER
61+
#if HAS_ITUPLE
6262
where TLabels : struct, ITuple, IEquatable<TLabels>
6363
#else
6464
where TLabels : struct, IEquatable<TLabels>
@@ -68,7 +68,7 @@ public static void Inc<TLabels>(this IMetricFamily<ICounter, TLabels> metricFami
6868
}
6969

7070
public static void Inc<TLabels>(this IMetricFamily<ICounter, TLabels> metricFamily, double increment, DateTimeOffset timestamp)
71-
#if NET6_0_OR_GREATER
71+
#if HAS_ITUPLE
7272
where TLabels : struct, ITuple, IEquatable<TLabels>
7373
#else
7474
where TLabels : struct, IEquatable<TLabels>
@@ -78,7 +78,7 @@ public static void Inc<TLabels>(this IMetricFamily<ICounter, TLabels> metricFami
7878
}
7979

8080
public static void IncTo<TLabels>(this IMetricFamily<ICounter, TLabels> metricFamily, double value)
81-
#if NET6_0_OR_GREATER
81+
#if HAS_ITUPLE
8282
where TLabels : struct, ITuple, IEquatable<TLabels>
8383
#else
8484
where TLabels : struct, IEquatable<TLabels>
@@ -88,7 +88,7 @@ public static void IncTo<TLabels>(this IMetricFamily<ICounter, TLabels> metricFa
8888
}
8989

9090
public static void IncTo<TLabels>(this IMetricFamily<ICounter, TLabels> metricFamily, double value, long timestamp)
91-
#if NET6_0_OR_GREATER
91+
#if HAS_ITUPLE
9292
where TLabels : struct, ITuple, IEquatable<TLabels>
9393
#else
9494
where TLabels : struct, IEquatable<TLabels>
@@ -98,7 +98,7 @@ public static void IncTo<TLabels>(this IMetricFamily<ICounter, TLabels> metricFa
9898
}
9999

100100
public static void IncTo<TLabels>(this IMetricFamily<ICounter, TLabels> metricFamily, double value, DateTimeOffset timestamp)
101-
#if NET6_0_OR_GREATER
101+
#if HAS_ITUPLE
102102
where TLabels : struct, ITuple, IEquatable<TLabels>
103103
#else
104104
where TLabels : struct, IEquatable<TLabels>

src/Prometheus.Client.Abstractions/CounterInt64Extensions.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
#if NET6_0_OR_GREATER
2+
#if HAS_ITUPLE
33
using System.Runtime.CompilerServices;
44
#endif
55

@@ -48,7 +48,7 @@ public static void IncTo(this IMetricFamily<ICounter<long>> metricFamily, long v
4848
}
4949

5050
public static void Inc<TLabels>(this IMetricFamily<ICounter<long>, TLabels> metricFamily, long increment = 1)
51-
#if NET6_0_OR_GREATER
51+
#if HAS_ITUPLE
5252
where TLabels : struct, ITuple, IEquatable<TLabels>
5353
#else
5454
where TLabels : struct, IEquatable<TLabels>
@@ -58,7 +58,7 @@ public static void Inc<TLabels>(this IMetricFamily<ICounter<long>, TLabels> metr
5858
}
5959

6060
public static void Inc<TLabels>(this IMetricFamily<ICounter<long>, TLabels> metricFamily, long increment, long timestamp)
61-
#if NET6_0_OR_GREATER
61+
#if HAS_ITUPLE
6262
where TLabels : struct, ITuple, IEquatable<TLabels>
6363
#else
6464
where TLabels : struct, IEquatable<TLabels>
@@ -68,7 +68,7 @@ public static void Inc<TLabels>(this IMetricFamily<ICounter<long>, TLabels> metr
6868
}
6969

7070
public static void Inc<TLabels>(this IMetricFamily<ICounter<long>, TLabels> metricFamily, long increment, DateTimeOffset timestamp)
71-
#if NET6_0_OR_GREATER
71+
#if HAS_ITUPLE
7272
where TLabels : struct, ITuple, IEquatable<TLabels>
7373
#else
7474
where TLabels : struct, IEquatable<TLabels>
@@ -78,7 +78,7 @@ public static void Inc<TLabels>(this IMetricFamily<ICounter<long>, TLabels> metr
7878
}
7979

8080
public static void IncTo<TLabels>(this IMetricFamily<ICounter<long>, TLabels> metricFamily, long value)
81-
#if NET6_0_OR_GREATER
81+
#if HAS_ITUPLE
8282
where TLabels : struct, ITuple, IEquatable<TLabels>
8383
#else
8484
where TLabels : struct, IEquatable<TLabels>
@@ -88,7 +88,7 @@ public static void IncTo<TLabels>(this IMetricFamily<ICounter<long>, TLabels> me
8888
}
8989

9090
public static void IncTo<TLabels>(this IMetricFamily<ICounter<long>, TLabels> metricFamily, long value, long timestamp)
91-
#if NET6_0_OR_GREATER
91+
#if HAS_ITUPLE
9292
where TLabels : struct, ITuple, IEquatable<TLabels>
9393
#else
9494
where TLabels : struct, IEquatable<TLabels>
@@ -98,7 +98,7 @@ public static void IncTo<TLabels>(this IMetricFamily<ICounter<long>, TLabels> me
9898
}
9999

100100
public static void IncTo<TLabels>(this IMetricFamily<ICounter<long>, TLabels> metricFamily, long value, DateTimeOffset timestamp)
101-
#if NET6_0_OR_GREATER
101+
#if HAS_ITUPLE
102102
where TLabels : struct, ITuple, IEquatable<TLabels>
103103
#else
104104
where TLabels : struct, IEquatable<TLabels>

src/Prometheus.Client.Abstractions/GaugeExtensions.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
#if NET6_0_OR_GREATER
2+
#if HAS_ITUPLE
33
using System.Runtime.CompilerServices;
44
#endif
55

@@ -108,7 +108,7 @@ public static void Set(this IMetricFamily<IGauge> metricFamily, double value, Da
108108
}
109109

110110
public static void Inc<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double increment = 1)
111-
#if NET6_0_OR_GREATER
111+
#if HAS_ITUPLE
112112
where TLabels : struct, ITuple, IEquatable<TLabels>
113113
#else
114114
where TLabels : struct, IEquatable<TLabels>
@@ -118,7 +118,7 @@ public static void Inc<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily
118118
}
119119

120120
public static void Inc<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double increment, long timestamp)
121-
#if NET6_0_OR_GREATER
121+
#if HAS_ITUPLE
122122
where TLabels : struct, ITuple, IEquatable<TLabels>
123123
#else
124124
where TLabels : struct, IEquatable<TLabels>
@@ -128,7 +128,7 @@ public static void Inc<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily
128128
}
129129

130130
public static void Inc<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double increment, DateTimeOffset timestamp)
131-
#if NET6_0_OR_GREATER
131+
#if HAS_ITUPLE
132132
where TLabels : struct, ITuple, IEquatable<TLabels>
133133
#else
134134
where TLabels : struct, IEquatable<TLabels>
@@ -138,7 +138,7 @@ public static void Inc<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily
138138
}
139139

140140
public static void IncTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double value)
141-
#if NET6_0_OR_GREATER
141+
#if HAS_ITUPLE
142142
where TLabels : struct, ITuple, IEquatable<TLabels>
143143
#else
144144
where TLabels : struct, IEquatable<TLabels>
@@ -148,7 +148,7 @@ public static void IncTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFami
148148
}
149149

150150
public static void IncTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double value, long timestamp)
151-
#if NET6_0_OR_GREATER
151+
#if HAS_ITUPLE
152152
where TLabels : struct, ITuple, IEquatable<TLabels>
153153
#else
154154
where TLabels : struct, IEquatable<TLabels>
@@ -158,7 +158,7 @@ public static void IncTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFami
158158
}
159159

160160
public static void IncTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double value, DateTimeOffset timestamp)
161-
#if NET6_0_OR_GREATER
161+
#if HAS_ITUPLE
162162
where TLabels : struct, ITuple, IEquatable<TLabels>
163163
#else
164164
where TLabels : struct, IEquatable<TLabels>
@@ -168,7 +168,7 @@ public static void IncTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFami
168168
}
169169

170170
public static void Dec<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double decrement = 1)
171-
#if NET6_0_OR_GREATER
171+
#if HAS_ITUPLE
172172
where TLabels : struct, ITuple, IEquatable<TLabels>
173173
#else
174174
where TLabels : struct, IEquatable<TLabels>
@@ -178,7 +178,7 @@ public static void Dec<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily
178178
}
179179

180180
public static void Dec<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double decrement, long timestamp)
181-
#if NET6_0_OR_GREATER
181+
#if HAS_ITUPLE
182182
where TLabels : struct, ITuple, IEquatable<TLabels>
183183
#else
184184
where TLabels : struct, IEquatable<TLabels>
@@ -188,7 +188,7 @@ public static void Dec<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily
188188
}
189189

190190
public static void Dec<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double decrement, DateTimeOffset timestamp)
191-
#if NET6_0_OR_GREATER
191+
#if HAS_ITUPLE
192192
where TLabels : struct, ITuple, IEquatable<TLabels>
193193
#else
194194
where TLabels : struct, IEquatable<TLabels>
@@ -198,7 +198,7 @@ public static void Dec<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily
198198
}
199199

200200
public static void DecTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double value)
201-
#if NET6_0_OR_GREATER
201+
#if HAS_ITUPLE
202202
where TLabels : struct, ITuple, IEquatable<TLabels>
203203
#else
204204
where TLabels : struct, IEquatable<TLabels>
@@ -208,7 +208,7 @@ public static void DecTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFami
208208
}
209209

210210
public static void DecTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double value, long timestamp)
211-
#if NET6_0_OR_GREATER
211+
#if HAS_ITUPLE
212212
where TLabels : struct, ITuple, IEquatable<TLabels>
213213
#else
214214
where TLabels : struct, IEquatable<TLabels>
@@ -218,7 +218,7 @@ public static void DecTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFami
218218
}
219219

220220
public static void DecTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double value, DateTimeOffset timestamp)
221-
#if NET6_0_OR_GREATER
221+
#if HAS_ITUPLE
222222
where TLabels : struct, ITuple, IEquatable<TLabels>
223223
#else
224224
where TLabels : struct, IEquatable<TLabels>
@@ -228,7 +228,7 @@ public static void DecTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFami
228228
}
229229

230230
public static void Set<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double value)
231-
#if NET6_0_OR_GREATER
231+
#if HAS_ITUPLE
232232
where TLabels : struct, ITuple, IEquatable<TLabels>
233233
#else
234234
where TLabels : struct, IEquatable<TLabels>
@@ -238,7 +238,7 @@ public static void Set<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily
238238
}
239239

240240
public static void Set<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double value, long timestamp)
241-
#if NET6_0_OR_GREATER
241+
#if HAS_ITUPLE
242242
where TLabels : struct, ITuple, IEquatable<TLabels>
243243
#else
244244
where TLabels : struct, IEquatable<TLabels>
@@ -248,7 +248,7 @@ public static void Set<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily
248248
}
249249

250250
public static void Set<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double value, DateTimeOffset timestamp)
251-
#if NET6_0_OR_GREATER
251+
#if HAS_ITUPLE
252252
where TLabels : struct, ITuple, IEquatable<TLabels>
253253
#else
254254
where TLabels : struct, IEquatable<TLabels>

0 commit comments

Comments
 (0)