PreserveAttribute.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* Copyright 2020-present MongoDB Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. using System;
  16. using System.ComponentModel;
  17. namespace MongoDB.Bson
  18. {
  19. /// <summary>
  20. /// Prevents the Xamarin managed linker from stripping the target.
  21. /// </summary>
  22. [AttributeUsage(AttributeTargets.All)]
  23. [EditorBrowsable(EditorBrowsableState.Never)]
  24. [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "Copied from the doc: https://docs.microsoft.com/en-us/xamarin/ios/deploy-test/linker?tabs=windows#preserving-code")]
  25. public sealed class PreserveAttribute : Attribute
  26. {
  27. /// <summary>
  28. /// When used on a class rather than a property, ensures that all members of this type are preserved.
  29. /// </summary>
  30. public bool AllMembers;
  31. /// <summary>
  32. /// Flags the method as a method to preserve during linking if the container class is pulled in.
  33. /// </summary>
  34. public bool Conditional;
  35. }
  36. }