Draw a line in local space of a GameObject

I need to create border for my sprite. I have attached a LineRenderer component to the GameObject which also has this sprite. At runtime I am getting coordinates of renderer using bounds.

        Vector2 extents = gameObject.GetComponent<Renderer>().bounds.extents;

Then with some +/- logic I get the coordinates.

        Vector3 TopLeftCornerPosition = gameObject.transform.position;

        TopLeftCornerPosition.x -= extents.x;
        TopLeftCornerPosition.y += extents.y;

I am using these coordinates in LineRenderer to set four positions.

LineRenderer.SetPositions(blockCorners);

But when LineRenderer’s ‘Use World Space’ option is checked, it does draw the line but when I move this block object, the line border does not move along with it though for LineRenderer block is the parent.

When I uncheck ’ User World Space’ Option, I see the box drawn by LineRenderer’ but it’s scale is almost 1/3 times then the block or sprites. But it moves along with the block. How can I fix it.

Please refer the attached screenshotsalt text

Then try to use localBounds

Thanks. I have already tried that but localBounds property is not available in

        gameObject.GetComponent<Renderer>()

Then as suggested in this post I have tried to use

        gameObject.GetComponent<SpriteRenderer>().bounds.extents;

which gives same values as localBounds but even that didn’t work.