Skip to content

Commit bd2fccc

Browse files
committed
Merge branch 'main' into release/3.0
2 parents ec04597 + b2afa17 commit bd2fccc

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
_No unreleased changes_
1111

12+
## [3.0.0-pre19] - 2025-01-16
13+
14+
### Changed
15+
- Avoid memory allocation while writing logs in EnvironmentContext by @TimLariviere
16+
1217
## [3.0.0-pre18] - 2025-01-16
1318

1419
### Changed
@@ -211,7 +216,8 @@ _No unreleased changes_
211216
### Changed
212217
- Fabulous.XamarinForms & Fabulous.MauiControls have been moved been out of the Fabulous repository. Find them in their own repositories: [https://github.com/fabulous-dev/Fabulous.XamarinForms](https://github.com/fabulous-dev/Fabulous.XamarinForms) / [https://github.com/fabulous-dev/Fabulous.MauiControls](https://github.com/fabulous-dev/Fabulous.MauiControls)
213218

214-
[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/3.0.0-pre18...HEAD
219+
[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/3.0.0-pre19...HEAD
220+
[3.0.0-pre18]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre19
215221
[3.0.0-pre18]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre18
216222
[3.0.0-pre17]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre17
217223
[3.0.0-pre16]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre16

src/Fabulous/EnvironmentContext.fs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,17 @@ and [<AllowNullLiteral>] EnvironmentContext(logger: Logger, inheritedContext: En
2121

2222
do
2323
if inheritedContext = null then
24-
logger.Log(LogLevel.Debug, $"EnvironmentContext '{id}' created")
24+
logger.Debug("EnvironmentContext '{0}' created", id)
2525
else
26-
logger.Log(LogLevel.Debug, $"EnvironmentContext '{id}' created and inherited from '{inheritedContext.Id}'")
26+
logger.Debug("EnvironmentContext '{0}' created and inherited from '{1}'", id, inheritedContext.Id)
2727

2828
let valuePropagationSubscription =
2929
if inheritedContext = null then
3030
null
3131
else
3232
inheritedContext.ValueChanged.Subscribe(fun args ->
33-
logger.Log(LogLevel.Debug, let (EnvironmentAttributeKey key) = args.Key in $"Env '{id}': Propagating '{key}' change from '{args.OriginEnvId}'")
33+
let (EnvironmentAttributeKey key) = args.Key
34+
logger.Debug("Env '{0}': Propagating '{1}' change from '{2}'", id, key, args.OriginEnvId)
3435
valueChanged.Trigger(args))
3536

3637
new(logger: Logger) = new EnvironmentContext(logger, null)
@@ -46,7 +47,8 @@ and [<AllowNullLiteral>] EnvironmentContext(logger: Logger, inheritedContext: En
4647
ValueNone
4748

4849
member internal this.SetInternal<'T>(key: EnvironmentAttributeKey, value: 'T, fromUserCode: bool) =
49-
logger.Log(LogLevel.Debug, let (EnvironmentAttributeKey key) = key in $"EnvironmentContext '{id}' set value '{key}' to '{value}'")
50+
let (EnvironmentAttributeKey envKey) = key
51+
logger.Debug("EnvironmentContext '{0}' set value '{1}' to '{2}'", id, envKey, value)
5052
let boxedValue = box value
5153
values[key] <- boxedValue
5254
valueChanged.Trigger(EnvironmentValueChanged(id, fromUserCode, key, ValueSome boxedValue))
@@ -68,7 +70,8 @@ and [<AllowNullLiteral>] EnvironmentContext(logger: Logger, inheritedContext: En
6870
let fromUserCode = defaultArg fromUserCode true
6971

7072
if values.ContainsKey(key.Key) || inheritedContext = null then
71-
logger.Log(LogLevel.Debug, let (EnvironmentAttributeKey key) = key.Key in $"EnvironmentContext '{id}' set value '{key}' to '{value}'")
73+
let (EnvironmentAttributeKey envKey) = key.Key
74+
logger.Debug(envKey, "EnvironmentContext '{0}' set value '{1}' to '{2}'", id, key, value)
7275
let boxedValue = box value
7376
values[key.Key] <- boxedValue
7477
valueChanged.Trigger(EnvironmentValueChanged(id, fromUserCode, key.Key, ValueSome boxedValue))
@@ -77,7 +80,7 @@ and [<AllowNullLiteral>] EnvironmentContext(logger: Logger, inheritedContext: En
7780

7881
interface IDisposable with
7982
member this.Dispose() =
80-
logger.Log(LogLevel.Debug, $"EnvironmentContext '{id}' disposed")
83+
logger.Debug("EnvironmentContext '{0}' disposed", id)
8184

8285
if valuePropagationSubscription <> null then
8386
valuePropagationSubscription.Dispose()

0 commit comments

Comments
 (0)