L E F L I
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
ZILtoid1991@lemmy.world to Programmer Humor@programming.dev · 1 day ago

All Borrow Checkers Are Bastards (ABCAB - 12312)

lemmy.world

message-square
20
link
fedilink
154

All Borrow Checkers Are Bastards (ABCAB - 12312)

lemmy.world

ZILtoid1991@lemmy.world to Programmer Humor@programming.dev · 1 day ago
message-square
20
link
fedilink
  • tias@discuss.tchncs.de
    link
    fedilink
    arrow-up
    5
    ·
    24 hours ago

    Maybe you’re thinking of IDisposable with the using keyword. The problem with that is that you have to remember to use it in every call site. Nothing stops a caller from writing var x = new Foo() and walking away.

    • 𝙲𝚑𝚊𝚒𝚛𝚖𝚊𝚗 𝙼𝚎𝚘𝚠@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      7 hours ago

      I am, but you can use a custom analyzer to stop it from compiling if misused. So you can actually stop a caller from writing that and walking away :)

    • Zarobi@aussie.zone
      link
      fedilink
      English
      arrow-up
      0
      ·
      10 hours ago

      You can make it a compilation error via configuration of project, but I forget exactly how to do it. Some magic Microsoft thing. I made it an error in my last project and fixed it up

      • FooBarrington@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        9 hours ago

        https://www.jetbrains.com/help/resharper/Reference__Code_Annotation_Attributes.html#MustDisposeResourceAttribute

        This one, I’m guessing? At least that’s the one I know.

        • Zarobi@aussie.zone
          link
          fedilink
          English
          arrow-up
          0
          ·
          9 hours ago

          It was an editorconfig file thing, but navigating the docs on mobile phone is horrendous so I can’t easily find it

          https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options

          There’s much more than is listed on that page

          • FooBarrington@lemmy.world
            link
            fedilink
            arrow-up
            2
            ·
            8 hours ago

            The editorconfig rules you’re referencing can turn code analyzer warnings into errors, but you still need a code analyzer to actually trigger the error.

            • Zarobi@aussie.zone
              link
              fedilink
              English
              arrow-up
              0
              ·
              8 hours ago

              Yeah I remember that project used Visual Studio on Windows. I’m not sure if it works outside of that environment

Programmer Humor@programming.dev

programmer_humor@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmer_humor@programming.dev

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
    • If the mod doesn’t find it funny, you’re banned. Ha-ha!.. For real: do not use the community for “statements”. There are other places for such content. Keep it chill and funny.
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 925 users / day
  • 3.83K users / week
  • 7K users / month
  • 14.9K users / 6 months
  • 1 local subscriber
  • 33.5K subscribers
  • 2.41K Posts
  • 86.1K Comments
  • Modlog
  • mods:
  • Feyter@programming.dev
  • adr1an@programming.dev
  • BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne@programming.dev
  • BE: 0.19.19
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org